How to Configure webpack4 to Convert ES6 to ES5

  1. Install the following modules (webpack 4.x | babel-loader 8.x | babel 7.x)

           npm i -D babel-loader @babel/core @babel/preset-env
     
         Or install the following modules (webpack 4.x | babel-loader 8.x | babel 7.x)

    npm i -D babel-loader@7 babel-core babel-preset-env
  2. Write the following configuration in webpack.config.js

            rules: [             { "test":/\\.m?js$/, use: {loader:"babel-loader", options:{presets:["@babel/preset-env"]}}, exclude:/node_modules|bower_components/}         ]

评论

暂无评论。

登录后可发表评论。