summaryrefslogtreecommitdiff
path: root/webpack.config.js
diff options
context:
space:
mode:
authormarudor <marudor@marudor.de>2018-11-27 21:45:04 +0100
committermsquare <msquare@notrademark.de>2018-12-07 16:47:33 +0100
commitc798aca98bca1e4c9901802efe845a04661949ff (patch)
treef2053df73708f00291f6ad557cf5695ff5ccbc69 /webpack.config.js
parent36b7f8d2a2c732725c8993e1df16d454c0e9d47c (diff)
modernize Stuff
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/webpack.config.js b/webpack.config.js
index 010a9667..8f1021fe 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,6 +1,7 @@
const path = require('path');
const webpack = require('webpack');
-const ExtractTextPlugin = require('extract-text-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const nodeEnv = (process.env.NODE_ENV || 'development').trim();
// eslint-disable-next-line
@@ -14,7 +15,10 @@ const plugins = [
NODE_ENV: JSON.stringify(nodeEnv),
},
}),
- new ExtractTextPlugin('[name].css'),
+ new MiniCssExtractPlugin({
+ filename: '[name].css',
+ chunkFilename: '[id]-[hash].css',
+ }),
];
@@ -24,6 +28,7 @@ for (let i = 0; i < 8; i++) {
}
module.exports = {
+ mode: __DEV__ ? 'development' : 'production',
context: __dirname,
resolve: {
extensions: ['.js', '.jsx'],
@@ -37,6 +42,9 @@ module.exports = {
filename: '[name].js',
publicPath: '',
},
+ optimization: {
+ minimizer: __DEV__ ? [] : [new OptimizeCSSAssetsPlugin({})],
+ },
module: {
rules: [
{
@@ -47,11 +55,16 @@ module.exports = {
},
{ test: /\.(eot|ttf|otf|svg|woff2?)(\?.*)?$/, loader: 'file-loader' },
{ test: /\.json$/, loader: 'json-loader' },
- { test: /\.css$/, loader: 'style-loader!css-loader' },
- { test: /\.less$/, use: ExtractTextPlugin.extract({
- fallback: 'style-loader',
- use: 'css-loader!less-loader'
- })}
+ {
+ test: /\.(less|css)$/,
+ use: [
+ {
+ loader: __DEV__ ? 'style-loader' : MiniCssExtractPlugin.loader,
+ },
+ { loader: 'css-loader', options: { importLoaders: 1 } },
+ { loader: 'less-loader' },
+ ]
+ }
],
},
plugins,