babel-loader not working? webpack
我想大声告诉你
我想大声告诉你 2017-05-18 11:01:26
0
2
702

Babel-loader is used to convert es6 code in webpack2, but the expected results are not seen in the final bundle.js. There are still es6 syntax, let, and default function parameter values. .

The following is the configuration part of my webpack:

var path = require("path");
var vuxLoader = require('vux-loader');
var webpack = require('webpack');

function resolve (dir) {
  return path.join(__dirname, '..', dir)
}

var webpackConfig = {
    entry: {
        // app: ["./app/cart.js"]
        app: ["./app/goodsDetail.js"]
        // app: ["./app/center.js"]
    },
      output: {
        path: path.resolve(__dirname, "build"),
        publicPath: "/",
        filename: "bundle.js"
     },
     module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                      // vue-loader options
                   }
              },
              {
              test: /\.js?$/,
              // exclude: /node_modules/,
              exclude: /node_modules/,
              loader: 'babel',
              query: {
                      presets: ['env']
                }
            }
        ]
    },
      resolve: {
        extensions: ['.js', '.vue', '.json']
    },
    devServer: {
        host: '0.0.0.0'
    },
    plugins: [
        new webpack.DefinePlugin({
          'process.env': {
            NODE_ENV: '"production"'
          }
        })
      ]
};

module.exports = vuxLoader.merge(webpackConfig,{
    plugins: ['vux-ui']
});

I searched and searched but could not find the reason. . .

我想大声告诉你
我想大声告诉你

reply all(2)
迷茫

Please create a new one
.babelrc

in the project root directory
{
    "presets": ["env"]
}
迷茫
babel: {
        presets: ['es2015', 'stage-2']
    }
    加上这部分试试
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template