我无法使用webpack转换es6默认参数 我目前的设置是:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: ["./main.js"],
output: { path: __dirname, filename: './bundle.js'},
resolve: {
modules: [path.resolve('../js'), path.resolve('../js/node_modules')],
extensions: ['*', '.ts', '.js', '.jsx', '.es6']
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' },
{
test: /(\.jsx?$|\.es6?$)/,
loader: 'babel-loader',
query: {
babelrc: false,
plugins: [
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping'
],
presets: ['es2016', 'react']
},
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"',
'global': {}, // bizarre lodash(?) webpack workaround
'global.GENTLY': false // superagent client fix
})
],
target: "node"
};
答案 0 :(得分:0)
您需要将参数transform plugins
添加到babel
。
plugins: [
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-parameters'
],