Optimize for production

This commit is contained in:
LordMathis 2018-06-21 12:42:32 +02:00
parent f5f008e5a4
commit 2716b342ed
3 changed files with 31 additions and 1 deletions

View File

@ -44,6 +44,7 @@
"css-modules-require-hook": "^4.0.6", "css-modules-require-hook": "^4.0.6",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"mini-css-extract-plugin": "^0.4.0", "mini-css-extract-plugin": "^0.4.0",
"optimize-css-assets-webpack-plugin": "^4.0.2",
"postcss-loader": "^2.1.4", "postcss-loader": "^2.1.4",
"sass-loader": "^7.0.1", "sass-loader": "^7.0.1",
"style-loader": "^0.21.0", "style-loader": "^0.21.0",

View File

@ -1,6 +1,8 @@
const { resolve, join } = require('path') const { resolve, join } = require('path')
const webpack = require('webpack') const webpack = require('webpack')
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
const MiniCssExtractPlugin = require("mini-css-extract-plugin") const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin")
const config = { const config = {
mode: 'production', mode: 'production',
@ -47,10 +49,23 @@ const config = {
{ {
test: /\.(png|jpg)$/, test: /\.(png|jpg)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'url-loader' loader: 'url-loader',
options: {
limit: 8192
}
}, },
] ]
}, },
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [ plugins: [
new MiniCssExtractPlugin({}) new MiniCssExtractPlugin({})
] ]

View File

@ -3674,6 +3674,13 @@ kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.2" version "6.0.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" 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"
lcid@^1.0.0: lcid@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835"
@ -4477,6 +4484,13 @@ onetime@^2.0.0:
dependencies: dependencies:
mimic-fn "^1.0.0" mimic-fn "^1.0.0"
optimize-css-assets-webpack-plugin@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-4.0.2.tgz#813d511d20fe5d9a605458441ed97074d79c1122"
dependencies:
cssnano "^3.10.0"
last-call-webpack-plugin "^3.0.0"
ora@^0.2.3: ora@^0.2.3:
version "0.2.3" version "0.2.3"
resolved "https://registry.yarnpkg.com/ora/-/ora-0.2.3.tgz#37527d220adcd53c39b73571d754156d5db657a4" resolved "https://registry.yarnpkg.com/ora/-/ora-0.2.3.tgz#37527d220adcd53c39b73571d754156d5db657a4"