From 236e127bef0b6c67f4f90860e5893e20603f162c Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Wed, 4 Apr 2018 13:38:47 +0200 Subject: [PATCH] feat(build-config): add CSS optimizer plugin to minify assets --- packages/build-config/configs/build.js | 13 +++++++++++++ packages/build-config/package.json | 2 ++ yarn.lock | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/build-config/configs/build.js b/packages/build-config/configs/build.js index a4b3e5c70..b0bf05b7c 100644 --- a/packages/build-config/configs/build.js +++ b/packages/build-config/configs/build.js @@ -6,6 +6,8 @@ var webpack = require('webpack'); var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; var ServiceWorkerPlugin = require('../plugins/service-worker'); var MiniCSSExtractPlugin = require('mini-css-extract-plugin'); +var UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin'); var hopsConfig = require('hops-config'); @@ -55,6 +57,17 @@ module.exports = { }, }, }, + minimizer: [ + new UglifyJSPlugin({ + cache: true, + parallel: true, + sourceMap: true, + uglifyOptions: { + output: { comments: false }, + }, + }), + new OptimizeCSSPlugin(), + ], }, plugins: [ new StatsWriterPlugin({ fields: null }), diff --git a/packages/build-config/package.json b/packages/build-config/package.json index 98a13065d..5f093122f 100644 --- a/packages/build-config/package.json +++ b/packages/build-config/package.json @@ -43,6 +43,7 @@ "lodash.template": "^4.4.0", "mini-css-extract-plugin": "^0.3.0", "mkdirp": "^0.5.1", + "optimize-css-assets-webpack-plugin": "^4.0.0", "pkg-dir": "^2.0.0", "postcss": "^6.0.16", "postcss-cssnext": "^3.0.2", @@ -50,6 +51,7 @@ "postcss-loader": "^2.0.10", "steed": "^1.1.3", "style-loader": "^0.20.0", + "uglifyjs-webpack-plugin": "^1.2.4", "url-loader": "^1.0.0", "webpack": "^4.3.0", "webpack-node-externals": "^1.6.0", diff --git a/yarn.lock b/yarn.lock index a3ba5c757..d1abce477 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2121,7 +2121,7 @@ cssesc@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-0.1.0.tgz#c814903e45623371a0477b40109aaafbeeaddbb4" -cssnano@^3.10.0: +cssnano@^3.10.0, cssnano@^3.4.0: version "3.10.0" resolved "https://registry.yarnpkg.com/cssnano/-/cssnano-3.10.0.tgz#4f38f6cea2b9b17fa01490f23f1dc68ea65c1c38" dependencies: @@ -4664,6 +4664,13 @@ kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" +last-call-webpack-plugin@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/last-call-webpack-plugin/-/last-call-webpack-plugin-3.0.0.tgz#9742df0e10e3cf46e5c0381c2de90d3a7a2d7555" + dependencies: + lodash "^4.17.5" + webpack-sources "^1.1.0" + lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" @@ -5550,6 +5557,13 @@ optimist@^0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" +optimize-css-assets-webpack-plugin@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-4.0.0.tgz#d5f80041fb1391b358a1f35273c3b53de814e8fe" + dependencies: + cssnano "^3.4.0" + last-call-webpack-plugin "^3.0.0" + optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"