webpack配置函數(shù)中沒有配置babel-loader來進(jìn)行es6代碼的轉(zhuǎn)換,也沒有配置.babelrc,那么在index.js中直接使用import不會報錯這是為什么??webpack.config.jsvar path = require('path');module.exports = { //入口
entry: {
main: './src/index.js',
},
output: { //所有產(chǎn)出資源路徑
path: path.join(__dirname, 'dist'),
filename: 'main.js',
},
}index.jsimport './a.js';console.log("我是index");
1 回答

浮云間
TA貢獻(xiàn)1829條經(jīng)驗 獲得超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 關(guān)注
- 656 瀏覽
添加回答
舉報
0/150
提交
取消