webpack.config.js:
module.exports = {
entry: __dirname + '/src/app.js',
output: {
path: __dirname + '/dist',
filename: 'test.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', {
targets: {
chrome: 52
}
}]
}
}
}
]
}
};
Looks simple, yet it throws error
Module build failed: ReferenceError: [BABEL] /src/app.js: Unknown option: foreign.targets. Check out http://babeljs.io/docs/usage/options/ for more information about options.
that doesn't make any sense. Error is triggered by options for "env" preset. Any ideas why babel preset suddenly doesn't accept options?
Figured it out. Preset with options should be in nested array, so correct options list should be like this:
options: {
presets: [
['env', {
targets: {
chrome: 52
}
}]
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With