Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 丑陋,无法读取属性';重置';未定义的_Javascript_Webpack - Fatal编程技术网

Javascript 丑陋,无法读取属性';重置';未定义的

Javascript 丑陋,无法读取属性';重置';未定义的,javascript,webpack,Javascript,Webpack,我使用webpack2构建我的应用程序,但是当使用uglify js+uglifyjs webpack插件时,我遇到了一些问题: 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-web

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

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)
“重置”是什么意思?我在任何地方都找不到答案。。。 谢谢

对我有用:

  npm install uglifyjs-webpack-plugin --save-dev

 plugins: [
    new webpack.optimize.UglifyJsPlugin()
]
但这是行不通的:

  new UglifyJSPlugin({
        compress: true
    })
Github也提出了同样的问题,答案是:

目前使用UglifyJS 3会破坏插件。它有一个新的API,因此插件必须相应地更改


编辑2017年8月: 现在uglifyjs网页包插件

安装插件:
npm安装uglifyjs网页包插件——保存dev
,然后在网页包配置中:

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

我这样做只是为了解决这个问题:

npm install --save-dev uglify-js@2
您必须确保您使用的是丑陋2而不是丑陋3。
我的配置如下所示:

const webpack = require('webpack');

module.exports = {
    ...
    plugins: [
        new webpack.optimize.UglifyJsPlugin()
    ]
};

2017-07-26

我通过以下方式解决了这个问题:

npm i-D uglifyjs网页包-plugin@1.0.0-beta.2

原因:
uglifyjs网页包-plugin@0.4.x
网页使用的版本,不支持uglify js 3。自
uglifyjs网页包-plugin@1.0.0-beta版,它开始支持uglify js 3

参考:


  • 它与webpack3+angular4配合使用
    npm安装丑陋-js@2.8.27--save dev

    将index.js发送到F:\Github\Program\My test\Webpack\wwww2\node\u modules\uglifyjs Webpack plugin\dist\index.jsI,也有同样的问题。作为一种解决方法:安装3.0.0而不是3.0.3,问题将暂时消失……这是Webpack 2和UglifyJS 3的问题。只需将UglifyJS2.8与Webpack2配合使用即可。
    const webpack = require('webpack');
    
    module.exports = {
        ...
        plugins: [
            new webpack.optimize.UglifyJsPlugin()
        ]
    };