npm install compression-webpack-plugin
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
/*从这里开始添加*/
configureWebpack: config => {
if(process.env.NODE_ENV === 'production'){
return {
plugins: [new CompressionPlugin({
test: /\.js$|\.html$|\.css/,
threshold: 10240,
deleteOriginalAssets: false
})]
}
}
}
/*到这里结束*/
};
location / {
root e:\workgit\abc;
error_page 405 =200 http://$host:8085/$request_uri;
index index.html index.htm;
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.*)$ /index.html last;
}
location / {
root e:\workgit\abc;
error_page 405 =200 http://$host:8085/$request_uri;
gzip on;
gzip_static on;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/plain application/json application/x-javascript application/css application/xml application/xml+rss text/javascript application/x-httpd-php image/jpeg image/gif image/png image/x-ms-bmp;
index index.html index.htm;
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.*)$ /index.html last;
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |