According to the tutorial configuration file as follows:
var WebPACK = the require ( 'WebPACK' ); var HtmlwebpackPlugin = the require ( 'HTML-WebPACK-plugin' ); var ExtractTextPlugin = the require ( 'Extract-text-WebPACK-plugin' ); var Merge = the require ( 'WebPACK-Merge' ); var webpackBaseConfig = the require ( './ webpack.config.js' ); // clear the basic configuration of a widget list webpackBaseConfig.plugins = []; module.exports = Merge (webpackBaseConfig, { Output: { publicPath: ' / dist / ' , // the file is renamed with the inlet 20 worth unique hash file filename: "[name] [hash] .js'. }, plugins:[ new ExtractTextPlugin ({ // extract CSS, and renamed with a unique file 20 for the hash worth filename: '. [name] [hash] .css' , allChunks: to true }), // define the current node environment for the production environment new webpack.DefinePlugin ({ 'process.env' : { NODE_ENV: ' "Production"' } }), // compression JS new new webpack.optimize.UglifyJsPlugin ({ the compress: { Represents warnings: to false } }), // extraction template, entrance html file and save new HtmlwebpackPlugin({ filename:'../index_prod.html', template:'./index.ejs', inject:false }) ] });
Error:
The reason: The reason given is that webpack4 has been upgraded does not support such an approach, and that is not in the plugins which to operate. But on the inside optimization, the wording unchanged paste the code below
Solution:
Run npm install --save-dev uglifyjs-webpack-plugin installed uglifyjsPlugin
Modify the configuration is as follows:
...... const UglifyJsPlugin = the require ( 'UglifyJS-WebPACK-plugin' ); // clear the basic configuration of a widget list webpackBaseConfig.plugins = []; module.exports = Merge (webpackBaseConfig, { Output: { publicPath: ' / dist / ' , // the file is renamed with the inlet 20 worth unique hash file filename:' [name] [hash] .js'. }, plugins: [ ...... ], Optimization: { Minimizer: [ new new UglifyJsPlugin ({ uglifyOptions: { Output: { Comments: to false }, compress: { warnings: false, drop_debugger: true, drop_console: true } } }) ] } });