Skip to content

Commit a10cd24

Browse files
author
Knut Behrends
committed
replace ExtractTextPlugin with ExtractTextPlugin, see webpack-contrib/extract-text-webpack-plugin#701 (comment)
1 parent e0ea3d6 commit a10cd24

File tree

3 files changed

+103
-53
lines changed

3 files changed

+103
-53
lines changed

package-lock.json

Lines changed: 71 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
"eslint-plugin-vue": "^4.7.1",
4848
"eslint-watch": "^3.1.5",
4949
"express": "^4.16.3",
50-
"extract-text-webpack-plugin": "^3.0.2",
5150
"faker": "^4.1.0",
5251
"html-webpack-plugin": "3.2.0",
5352
"jsdom": "7.2.2",
5453
"json-schema-faker": "^0.5.0-rc15",
5554
"json-server": "^0.14.0",
5655
"localtunnel": "^1.9.1",
56+
"mini-css-extract-plugin": "^0.4.3",
5757
"mocha": "^5.2.0",
5858
"nock": "^9.6.1",
5959
"npm-run-all": "^4.1.3",

webpack.config.prod.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import webpack from 'webpack';
22
import path from 'path';
33
import HtmlWebpackPlugin from 'html-webpack-plugin';
44
import WebpackMd5Hash from 'webpack-md5-hash';
5-
import ExtractTextPlugin from 'extract-text-webpack-plugin';
5+
//import ExtractTextPlugin from 'extract-text-webpack-plugin';
6+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
67
//debug: true,
78
//noInfo: false,
89

@@ -11,14 +12,14 @@ export default {
1112
resolve: {
1213
extensions: ['*', '.js', '.jsx', '.json']
1314
},
14-
devtool: 'source-map',
15+
devtool: 'source-map', //higher quality than 'inline-source-maps'
1516
entry: {
1617
vendor: path.resolve(__dirname, 'src/vendor'),
1718
main: path.resolve(__dirname, 'src/index')
1819
},
1920
target: 'web',
2021
output: {
21-
path: path.resolve(__dirname, 'dist'),
22+
path: path.resolve(__dirname, 'dist'), // new
2223
publicPath: '/',
2324
filename: '[name].[chunkhash].js'
2425
},
@@ -45,7 +46,8 @@ export default {
4546
// (separate css and js)
4647
// Generate an external css file with a hash in the filename
4748
//new ExtractTextPlugin('[name].[contenthash].css'),
48-
new ExtractTextPlugin('[name].[md5:contenthash:hex:20].css'),
49+
new MiniCssExtractPlugin('[name].[md5:contenthash:hex:20].css'),
50+
//new ExtractTextPlugin('[name].[md5:contenthash:hex:20].css'),
4951
// Hash the files using MD5 so that their names change when the content changes.
5052
new WebpackMd5Hash(),
5153

@@ -67,7 +69,7 @@ export default {
6769
removeEmptyAttributes: true,
6870
removeStyleLinkTypeAttributes: true,
6971
keepClosingSlash: true,
70-
minifyJS: true,
72+
minifyJS: true, // replaces UglifyJSPlugin
7173
minifyCSS: true,
7274
minifyURLs: true
7375
},
@@ -86,11 +88,31 @@ export default {
8688
],
8789
module: {
8890
rules: [
89-
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader'] },
91+
// { test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader'] },
92+
// {
93+
// test: /\.css$/,
94+
// loader: ExtractTextPlugin.extract('css-loader?sourceMap')
95+
// } // extra param is a hint to webpack
9096
{
9197
test: /\.css$/,
92-
loader: ExtractTextPlugin.extract('css-loader?sourceMap')
93-
} // extra param is a hint to webpack
94-
]
98+
use: [
99+
{
100+
loader: MiniCssExtractPlugin.loader
101+
},
102+
103+
{
104+
loader: 'css-loader',
105+
options: {
106+
sourceMap: true,
107+
modules: true,
108+
localIdentName: '[local]___[hash:base64:5]'
109+
}
110+
},
111+
112+
// {
113+
// loader: 'postcss-loader'
114+
// }
115+
]
116+
}]
95117
}
96118
};

0 commit comments

Comments
 (0)