webpack配置函数中没有配置babel-loader来进行es6代码的转换,也没有配置.babelrc,那么在index.js中直接使用import不会报错这是为什么??webpack.config.jsvar path = require('path');module.exports = { //入口
entry: {
main: './src/index.js',
},
output: { //所有产出资源路径
path: path.join(__dirname, 'dist'),
filename: 'main.js',
},
}index.jsimport './a.js';console.log("我是index");
1 回答
浮云间
TA贡献1829条经验 获得超4个赞
我想你没有明白babel
是干什么的
Babel is a JavaScript compiler
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:
Transform syntax
Polyfill features that are missing in your target environment (through * @babel/polyfill)
Source code transformations (codemods)
And more! (check out these videos for inspiration)
- 1 回答
- 0 关注
- 635 浏览
添加回答
举报
0/150
提交
取消