Browse Source

Build: Minimizing css and js for Element doc site (#14430)

* build: build css minimizing for production

* build: JS Minimizing For Production

* build: run only in production
iamkun 6 years ago
parent
commit
4aa85ef3c8
3 changed files with 581 additions and 12 deletions
  1. 14 1
      build/webpack.demo.js
  2. 2 0
      package.json
  3. 565 11
      yarn.lock

+ 14 - 1
build/webpack.demo.js

@@ -5,6 +5,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
 const HtmlWebpackPlugin = require('html-webpack-plugin');
 const ProgressBarPlugin = require('progress-bar-webpack-plugin');
 const VueLoaderPlugin = require('vue-loader/lib/plugin');
+const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
 const md = require('markdown-it')();
 const slugify = require('transliteration').slugify;
 
@@ -185,7 +187,10 @@ const webpackConfig = {
         }
       }
     })
-  ]
+  ],
+  optimization: {
+    minimizer: []
+  }
 };
 
 if (isProd) {
@@ -194,6 +199,14 @@ if (isProd) {
       filename: '[name].[contenthash:7].css'
     })
   );
+  webpackConfig.optimization.minimizer.push(
+    new UglifyJsPlugin({
+      cache: true,
+      parallel: true,
+      sourceMap: false
+    }),
+    new OptimizeCSSAssetsPlugin({})
+  );
 }
 
 module.exports = webpackConfig;

+ 2 - 0
package.json

@@ -110,6 +110,7 @@
     "mini-css-extract-plugin": "^0.4.1",
     "mocha": "^3.1.1",
     "node-sass": "^4.5.3",
+    "optimize-css-assets-webpack-plugin": "^5.0.1",
     "perspective.js": "^1.0.0",
     "postcss": "^5.1.2",
     "postcss-loader": "^2.1.5",
@@ -122,6 +123,7 @@
     "sinon-chai": "^2.8.0",
     "style-loader": "^0.19.0",
     "transliteration": "^1.1.11",
+    "uglifyjs-webpack-plugin": "^2.1.1",
     "uppercamelcase": "^1.1.0",
     "url-loader": "^1.0.1",
     "vue": "^2.5.16",

File diff suppressed because it is too large
+ 565 - 11
yarn.lock


Some files were not shown because too many files changed in this diff