Babel file is copied without being transformed

前端 未结 10 2314
礼貌的吻别
礼貌的吻别 2020-11-22 06:09

I have this code:

\"use strict\";

import browserSync from \"browser-sync\";
import httpProxy from \"http-proxy\";

let proxy = httpProxy.createProxyServer({         


        
10条回答
  •  梦如初夏
    2020-11-22 06:52

    As of 2020, Jan:

    STEP 1: Install the Babel presets:

    yarn add -D @babel/preset-env @babel/preset-react

    STEP 2: Create a file: babelrc.js and add the presets:

    module.exports = {
      // ...
      presets: ["@babel/preset-env", "@babel/preset-react"],
      // ...
    }
    

    STEP 3:- Install the babel-loader:

    yarn add -D babel-loader

    STEP 4:- Add the loader config in your webpack.config.js:

    {
    //...
      module: [
        rules: [
          test: /\.(js|mjs|jsx|ts|tsx)$/,
          loader: require.resolve('babel-loader')
        ]
      ]
    //...
    }
    

    Good Luck...

提交回复
热议问题