javascript - 反应:来自 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"]
}
解决方案
推荐阅读
- javascript - 使用主题道具的玩笑/酶测试不起作用
- java - 集合元素映射对于 Map 类型的列的列数错误
- automated-tests - cypress 中的测试是如何组织的
- module - 如何从父文件夹或同级文件夹模块访问模块?
- mysql - 如何在数据存储中存储大量 Python 字典并对其进行过滤/查询?
- windows - 使用 GCC/cmake 生成 DEF 和 .A 文件
- android - 滑动刷新布局下的 RecyclerView 未在嵌套滚动视图中显示
- javascript - 如何在 React 中传递多个键及其 HTML 标签属性
- javascript - Javascript AzureAd 消费休息服务
- point-cloud-library - 当前对 CUDA for PCL 的开发支持