Wayne State Web Team

Wayne State University Web Team Blog

Excluding slick carousel using webpack, babel and the UglifyJsPlugin

While learning webpack (opens new window) and babel (opens new window), our team had an issue with trying to run certain NPM packages through babel. Since we only want to pass ES2015 code through it, we need to exclude packages that don't use it. To do that you can specify certain folders under node_modules to ignore in your webpack.config.js file like this:


What this will do is exclude slick-carousel from going through babel-loader, but it will still be part of the JS build and make it's way down the pipe to the UglifyJsPlugin (opens new window). Note: the exclude is not a string so it should not have quotes around it.

Side Note:

It's possible to pass /node_modules/ and ignore all packages going through babel, but this wasn't what we needed. Zurb Foundation 6.2 (opens new window) requires passing code through babel, so excluding all of node_modules wasn't an option for us.