【发布时间】:2016-12-13 19:55:29
【问题描述】:
如何配置 Babel 和 Webpack 以在一个项目中加载 ES6 源代码和 ES5 供应商库,例如:jQuery,以及我们旧的 lib javascript 文件?它们都具有相同的 *.js 扩展名。
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
上面的 loader 会正确加载 ES6,但是把所有的 js 文件都当作 ES6。我在 ES5 中的旧 lib js 文件呢?
这是我的 .babelrc 文件:
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
}
【问题讨论】: