gpt4 book ai didi

javascript - 即使删除 uglify 配置后,配置仍会继续 uglify js

转载 作者:行者123 更新时间:2023-12-03 01:51:48 29 4
gpt4 key购买 nike

使用 webpack 4 我已部署到生产环境,其中一个页面在控制台中显示错误:

Error: [$injector:unpr] http://errors.angularjs.org/1.6.10/$injector/unpr?p0=eProvider%20%3C-%20e

并在 Angular 文档中显示

Unknown provider: eProvider <- e

人们说这条消息是因为丑化了你的脚本,并导致了这个无用的错误消息。因此,我从 webpack.prod.js 中删除了 Uglify 配置,并且脚本继续丑化,因此控制台仍然向我提供这个无用的错误。

我将在下面发布我的 webpack.common.jswebpack.prod.js 以便您查看,但我 90% 确定那里有是否没有留下会使脚本变得丑陋的配置?

问题

如何停止丑化以便我可以在控制台中看到错误源自何处?

webpack.common.js

const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const devMode = process.env.NODE_ENV !== 'production';

module.exports = {
devtool: "source-map",
entry: {
vendor: './src/js/vendor.js',
app: './src/js/index.js',
style: './src/scss/main.scss'
},
output: {
path: path.resolve(__dirname, "dist"),
filename: '[name].bundle.js'
},
resolve: {
alias: {
localScripts: path.resolve(__dirname, 'assets'),
app: path.resolve(__dirname, 'app'),
}
},
module: {
rules: [
{
test: /\.(png|jpg|gif|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
},
},
]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false, sourceMap: true } }
]
},
{
test: /\.scss$/,
include: [
path.resolve(__dirname, "./src/scss")
],
// exclude: [
// path.resolve(__dirname, "node_modules")
// ],
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: false, sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
}
]
},
// cache: false,
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new webpack.ContextReplacementPlugin(/\.\/locale$/, 'empty-module', false, /js$/), //needed for bug in moment
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
inject: false,
title: 'Patent Place',
template: 'index.htm'

}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
]
}

webpack.prod.js

const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");

module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin({
sourceMap: true,
filename: "main.css"
}),
//new UglifyJsPlugin({
//sourceMap: true,
//test: /\.js($|\?)/i,
//}),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
map: {
inline: true
}
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
});

最佳答案

您已在 Webpack 中启用生产模式。 This enables the UglifyJS plugin automatically :

production

Provides process.env.NODE_ENV with value production. Enables FlagDependencyUsagePlugin, FlagIncludedChunksPlugin, ModuleConcatenationPlugin, NoEmitOnErrorsPlugin, OccurrenceOrderPlugin, SideEffectsFlagPlugin and UglifyJsPlugin.

要禁用缩小,请将模式设置为开发或覆盖optimization.minimize和/或optimization.minimizer选项。

关于javascript - 即使删除 uglify 配置后,配置仍会继续 uglify js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50388493/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com