初识webpack(5)

1.babel将es6代码转换为es5

npm install --save-dev babel-loader @babel/core
npm install @babel/preset-env --save-dev
npm install --save @babel/polyfill

js代码

require("@babel/polyfill");
 1     module:{
 2           rules:[
 3              { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader",
 4               options:{
 5                   "presets": [["@babel/preset-env",{
 6                       useBuiltIns:"usage"
 7                   }]]
 8                 }
 9           },
10  ]
11  }

 

你可能感兴趣的:(初识webpack(5))