gpt4 book ai didi

javascript - Uglify,无法读取未定义的属性 'reset'

转载 作者:可可西里 更新时间:2023-11-01 01:47:38 26 4
gpt4 key购买 nike

我使用 webpack2 来构建我的应用程序,但是当使用 uglify-js + uglifyjs-webpack-plugin 时,我遇到了一些问题:

ERROR in vendors.js from UglifyJs
TypeError: Cannot read property 'reset' of undefined
at F:\Github\Program\My-test\Webpack\www2\node_modules\_uglifyjs-webpack-plugin@0.4.3@uglifyjs-webpack-plugin\dist\index.js:99:22
at F:\Github\Program\My-test\Webpack\www2\node_modules\_uglifyjs-webpack-plugin@0.4.3@uglifyjs-webpack-plugin\dist\index.js:231:9
at Array.forEach (native)
at Compilation.<anonymous> (F:\Github\Program\My-test\Webpack\www2\node_modules\_uglifyjs-webpack-plugin@0.4.3@uglifyjs-webpack-plugin\dist\index.js:54:19)
at Compilation.applyPluginsAsyncSeries (F:\Github\Program\My-test\Webpack\www2\node_modules\_tapable@0.2.6@tapable\lib\Tapable.js:142:13)
at self.applyPluginsAsync.err (F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compilation.js:635:10)
at Compilation.applyPluginsAsyncSeries (F:\Github\Program\My-test\Webpack\www2\node_modules\_tapable@0.2.6@tapable\lib\Tapable.js:131:46)
at sealPart2 (F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compilation.js:631:9)
at Compilation.applyPluginsAsyncSeries (F:\Github\Program\My-test\Webpack\www2\node_modules\_tapable@0.2.6@tapable\lib\Tapable.js:131:46)
at Compilation.seal (F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compilation.js:579:8)
at F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compiler.js:493:16
at F:\Github\Program\My-test\Webpack\www2\node_modules\_tapable@0.2.6@tapable\lib\Tapable.js:225:11
at _addModuleChain (F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compilation.js:481:11)
at processModuleDependencies.err (F:\Github\Program\My-test\Webpack\www2\node_modules\_webpack@2.5.1@webpack\lib\Compilation.js:452:13)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)

webpack 配置可能会给你一些帮助:

module.exports = {
entry: {
app: path.resolve(APP, 'index.js'),
vendors: ['jquery', 'moment']
},
output: {
path: BUILD,
filename: 'bundle.js'
},
plugins: [
new HTMLwebpackPlugin({
title: 'Generate by webpack'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
filename: 'vendors.js'
}),
new UglifyJSPlugin({
compress: true
})
],
module: {
loaders: [
{
test: /\.scss$/,
loaders: 'style-loader!css-loader?sourceMap!sass-loader?sourceMap',
include: APP
},
{
test: /\.(jpg|png)$/,
loaders: 'url-loader?limit=40000'
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
include: APP,
query: {
presets: ['es2015', {"modules": false}]
}
}
]
},
devtool: 'eval-source-map'
}

“重置”是什么意思?我无法在任何地方找到答案...谢谢!

最佳答案

编辑 2017 年 8 月:现在 uglifyjs-webpack-plugin works with uglify-js@3

安装插件:npm install uglifyjs-webpack-plugin --save-dev,然后在webpack config中:

var UglifyJSPlugin = require('uglifyjs-webpack-plugin')
...
plugins: [
new UglifyJSPlugin()
]

关于javascript - Uglify,无法读取未定义的属性 'reset',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43884201/

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