Javascript 网页包丑陋错误:意外标记:关键字(函数)

Javascript 网页包丑陋错误:意外标记:关键字(函数),javascript,babeljs,webpack-2,uglifyjs,angular1.6,Javascript,Babeljs,Webpack 2,Uglifyjs,Angular1.6,我正在尝试运行npm run build,但无法运行。 我正在使用Webpack2,但它在uglifyJs中给了我一个错误 来自UglifyJs的app.3E1E32973E4700ACF37.js 意外标记:关键字(函数)[app.3e1e32973e4700acf37.js:130155,20] UglifyJs中的app.bundle.js出错 这是我的包。json "devDependencies": { "angular-animate": "^1.6.4", "ang

我正在尝试运行npm run build,但无法运行。
我正在使用Webpack2,但它在uglifyJs中给了我一个
错误

来自UglifyJs的app.3E1E32973E4700ACF37.js
意外标记:关键字(函数)[app.3e1e32973e4700acf37.js:130155,20]
UglifyJs中的app.bundle.js出错

这是我的包。json

"devDependencies": {
    "angular-animate": "^1.6.4",
    "angular-aria": "^1.6.4",
    "angular-sanitize": "^1.6.4",     
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "copy-webpack-plugin": "4.0.1",    
    "html-webpack-plugin": "^2.7.1",    
    "postcss-loader": "1.2.2",
    "raw-loader": "^0.5.1",
    "rimraf": "^2.5.1",
    "style-loader": "^0.13.0",
    "webpack": "2.2.0",
    "webpack-dev-server": "2.2.0"
  }

"scripts": {
    "build": "rimraf dist && webpack -p --bail --progress --profile",
    "server": "webpack-dev-server --port 8080 --history-api-fallback --inline --progress",
    "start": "npm run server"
  },
这是我的webpack.config.js文件

config.module = {
    rules: [{
      // JS LOADER
      // Reference: https://github.com/babel/babel-loader
      // Transpile .js files using babel-loader
      // Compiles ES6 and ES7 into ES5 code
      test: /\.js$/,
      loader: 'babel-loader',**strong text**
      exclude: /node_modules/
    }
这是我的宝贝档案

{
  "presets": ["es2015"]
}
当我用这个新的test对象将webpack.config.js文件从js更改为es6

config.module = {
rules: [{
  // JS LOADER
  // Reference: https://github.com/babel/babel-loader
  // Transpile .js files using babel-loader
  // Compiles ES6 and ES7 into ES5 code
  test: /\.es6$/,
  loader: 'babel-loader',**strong text**
  exclude: /node_modules/
}
我从UglifyJs获得app.8c6dc5e29db45e3eb325.js中的错误 意外令牌:运算符(>)[app.8c6dc5e29db45e3eb325.js:5564,32]


请让我知道我在运行npm run build时做错了什么?

您需要以这种方式更改babel配置

"devDependencies": {    
    "babel-core": "^6.26.0",
    "babel-loader": "^6.4.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-latest": "^6.22.0",
    "babel-preset-stage-0": "^6.24.1"    
  }
更新您的LRC

{
  "presets": [
    "es2015",
    "stage-0"
  ],
  "plugins": [
    ["transform-runtime", {
      "helpers": false,
      "polyfill": false,
      "regenerator": true,
      "moduleName": "babel-runtime"
    }]
  ]
}
并将此配置用于网页包

  config.module = {
    rules: [{
      // JS LOADER
      // Reference: https://github.com/babel/babel-loader
      // Transpile .js files using babel-loader
      // Compiles ES6 and ES7 into ES5 code
      test: /\.js$/,
      exclude: /node_modules/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['env']
        }
      }
    },
这应该能奏效