首页 > 解决方案 > 反应:来自 UglifyJs 的 bundle.js 中的错误。意外的标记:

问题描述

来自 UglifyJs 的 bundle.js 中的错误意外令牌:名称(结果)[./node_modules/asn1.js/lib/asn1/base/node.js:282,0][bundle.js:44788,6]

在尝试为生产进行构建时。我该如何解决他的问题?我的 webpack 是 3.1.0。为 dev 编译似乎工作正常。

部分 Webpack.config.js

// entry point -> output point
const path = require("path");
const webpack = require("webpack");
//console.log();
const ExtractTextPlugin = require("extract-text-webpack-plugin");

// this is an environemtn variable that stores the environment you are currently in.
//automically set in heroku to production. it will be production, test, or development.
// we installed npm corss-env to setup the variable
process.env.NODE_ENV = process.env.NODE_ENV || "development";

// these can't go to the client
if (process.env.NODE_ENV === "test") {
  require("dotenv").config({ path: ".env.test" });
} else if (process.env.NODE_ENV === "development") {
  require("dotenv").config({ path: ".env.development" });
}

module.exports = (env) => {
  const isProduction = env === "production";
  const CSSExtract = new ExtractTextPlugin("styles.css");

  console.log("env", env);
  return {
    entry: ["babel-polyfill", "./src/app.js"],
    // entry: ["./src/app.js"],
    output: {
      path: path.join(__dirname, "public", "dist"),
      filename: "bundle.js",
    },
    module: {
      rules: [
        {
          loader: "babel-loader",
          test: /\.js$/,
          exclude: /node_modules/,
        },
       

和我的 .babelrc

  "presets": ["env", "react"],
  "plugins": ["transform-class-properties", "transform-object-rest-spread"]
}

标签: javascriptreactjswebpack

解决方案


推荐阅读