Solve the Vue-CLI WebPack package to open GZIP error

The previous two days is online, and Vue-CLI NPM Run Build command is packaged. After packaging is completed, I wiped a hop, 15m. I was not intended to be optimized, but every time I look at the deployment package so big, think about it, I will optimize it, let the bag look good, so that the psychological shadow will be left!

After drying the MAP file, discover the speed of the WebPack this package, it is also touching. When doing automatically generates the MAP file settings, there is a ProductionGzip feature that webpack comes with

ProductionGzip

, and the sure is a one-time drum.

The following is the juggling process, and it is almost drumping. 1, in the project root directory
config / index.js

found productiongzip: false, change False to TRUE. It is just the opposite of ProductionSourceMap.

解决vue-cli webpack打包开启Gzip 报错问题

After the value is modified, NPM Run Build can be performed at this time. However, it will report an error, prompting “Cannot Find Module ‘Compression-WebPack-Plugin'” [“

解决vue-cli webpack打包开启Gzip 报错问题

2, that is, the installation of compression-webpack-plugin official recommendation The command is: (but the net is not good, cool)

 NPM install --save-dev compression-webPack-plugin // No given version number When the command is installed by default, the latest version-WebPack-Plugin is installed. The problem is just here   
after the installation is complete, re-run npm run build
, then tragedy:

From an error display, it is known that the configuration option is failed, but which verification failed, or those item validation failed. , Open the error log, the more you look, the more you are, and a face is awkward. I didn't see it from the source code.

解决vue-cli webpack打包开启Gzip 报错问题 From the check parameters, the parameters are two, but the first parameter has a lot of attributes.

From the results, the verification of this line code is failed. As for what this line code is executed, the level is not enough to check.

解决vue-cli webpack打包开启Gzip 报错问题 The last didn’t get a law, only go to the official website https://www.npmjs.com/package/compression-webpack-plugin to see, there is a breakthrough. When you go in the first eye, I have aimed 2.0.0 • Public • Publish3 Months Ago, I feel a bit wrong, the general small version of the update is 1.xx.xx, very few such direct full, all zero Suitable for the upgrade update of the large version, then look at the configured item test, the option property does not match the option attribute. Suddenly there is a feeling of inexplicably. Then look at the introduction and document below, 1 first correspond to the Node version node@v8.11.3, still within the range. 2 Requirements: this Module Requires a Minimum of Node V6.9.0 and WebPack V4.0.0 (This module requires Nodev6.9.0 and WebPack V4.0.0), and I have a significant difference in WebPack version. This finally found the crux.

解决vue-cli webpack打包开启Gzip 报错问题 3, find the crux, it is simple. Since the latest version is too high, I can’t downgrade it with the Webpack high climbing.

1 unloadingThe latest version of the installed 2.0

Compression-WebPack-Plugin

installation package.

解决vue-cli webpack打包开启Gzip 报错问题 解决vue-cli webpack打包开启Gzip 报错问题 NPM Uninstall –Save-Dev Compression-WebPack-Plugin

解决vue-cli webpack打包开启Gzip 报错问题 2 Reinstall 1.1.12 version ( This version is the latest version of 1.1). Uninstalling can not be used, directly execute the installation command, and the version coverage is also possible.

npm install –save-dev compression-webpack-plugin@1.1.12 // Remember to bring version number

After installing, re-executing NPM Run Build
, finally succeeded, really fucking!   During the installation process, there is another problem. Net speed and wall problem: 
This is a good solution, using Taobao mirror. The installation process and the possible problems and solutions can be moved https://www.jb51.net/Article/166090.htm for reference!

  The above is the Solid-CLI Webpack package to open the Gzip error problem, I hope that everyone has helpful. If you have any questions, please leave a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!  If you think this article helps you, welcome to reprint, please indicate the source, thank you! 
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment