Babel file is copied without being transformed

前端 未结 10 2156
礼貌的吻别
礼貌的吻别 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

    First ensure you have the following node modules:

    npm i -D webpack babel-core babel-preset-es2015 babel-preset-stage-2 babel-loader

    Next, add this to your Webpack config file (webpack.config.js) :

    // webpack.config.js
    ...
    module  :  {
      loaders  :  [
        {
          test    :  /\.js$/,
          loader  :  'babel',
          exclude :  /node_modules/,
          options :  {
            presets  :  [ 'es2015', 'stage-2' ] // stage-2 if required
          } 
        } 
      ]
    }
    ...
    

    References:

    • https://gist.github.com/Couto/6c6164c24ae031bff935
    • https://github.com/babel/babel-loader/issues/214

    Good Luck!

提交回复
热议问题