Statements | Branches | Functions | Lines |
---|---|---|---|
Creating a regular expression for excluding node_modules
from babel transpiling except for individual modules
// webpack.config.js
const babelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except');
module.exports = {
// config properties
// ...
module: {
rules: [
{
test: /\.js$/,
exclude: babelLoaderExcludeNodeModulesExcept([
// es6 modules from node_modules/
'custom-jquery-methods',
'swiper',
'dom7'
]),
use: {
loader: 'babel-loader'
}
}
]
}
};
Since v1.2.0
// webpack.config.js
const babelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except');
module.exports = {
// config properties
// ...
module: {
rules: [
{
test: /\.js$/,
exclude: babelLoaderExcludeNodeModulesExcept([
'react-*',
'@awesomecorp/*'
]),
use: {
loader: 'babel-loader'
}
}
]
}
};
- April Arcus @AprilArcus
- Thordur Thordarson @earthslasthope