Webpacker: Struggling to make webpacker configuration change

Created on 14 Jan 2018  路  3Comments  路  Source: rails/webpacker

I've run into an issue with Zurb Foundation 6, which ships un-transpiled ES2015 code in its library. A similar issue to the one I'm experiencing is this one.

The solution suggested on that issue, and I've seen similar elsewhere, is to modify the exclude rule on the Babel plugin to not exclude node-modules/foundation-sites. The problem I'm having is that I can't see how to do that in webpacker, even after reading the configuration docs

Essentially, what I need to add is the following rule:

      exclude: /node_modules\/(?!(foundation-sites)\/).*/,

to the Babel loader. So far, I've failed miserably. Any help would be much appreciated!

Most helpful comment

You can add option like so:

// config/webpack/environment.js
const { environment } = require('@rails/webpacker')

const babelLoader = environment.loaders.get('babel')
babelLoader.exclude = /node_modules\/(?!(foundation-sites)\/).*/

module.exports = environment

All 3 comments

You can add option like so:

// config/webpack/environment.js
const { environment } = require('@rails/webpacker')

const babelLoader = environment.loaders.get('babel')
babelLoader.exclude = /node_modules\/(?!(foundation-sites)\/).*/

module.exports = environment

@gauravtiwari Thank you so much for helping! I'm pretty sure I would not have got there on my own :)

@gauravtiwari you are a lifesaver 馃憤

Was this page helpful?
0 / 5 - 0 ratings