Skip to content

Commit 0475085

Browse files
author
Gerkin
committed
build(demo,lib): Update deps, use webpack4
Due to webpack-contrib/mini-css-extract-plugin#257, [email protected] should be avoided. I expect next version to fix this issue.
1 parent 95c4565 commit 0475085

File tree

5 files changed

+21048
-1902
lines changed

5 files changed

+21048
-1902
lines changed

demo/webpack.config.js

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
var webpack = require('webpack'),
2-
CleanWebpackPlugin = require('clean-webpack-plugin'),
3-
HtmlWebpackPlugin = require('html-webpack-plugin'),
4-
ExtractTextPlugin = require('extract-text-webpack-plugin'),
5-
path = require('path');
1+
const webpack = require('webpack'),
2+
CleanWebpackPlugin = require('clean-webpack-plugin'),
3+
HtmlWebpackPlugin = require('html-webpack-plugin'),
4+
MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
path = require('path');
66

77
module.exports = {
8+
mode: 'production',
9+
810
entry: {
911
'polyfills': root('src', 'polyfills.ts'),
1012
'vendor': root('src', 'vendor.ts'),
1113
'app': root('src', 'main.ts')
1214
},
13-
15+
1416
output: {
1517
path: root('build'),
1618
filename: '[name].js',
1719
chunkFilename: '[id].chunk.js'
1820
},
19-
21+
2022
resolve: {
2123
extensions: ['.ts', '.js']
2224
},
23-
25+
2426
devServer: {
2527
historyApiFallback: true,
2628
stats: 'minimal',
@@ -29,7 +31,7 @@ module.exports = {
2931
inline: true,
3032
openPage: ''
3133
},
32-
34+
3335
module: {
3436
rules: [
3537
{
@@ -47,10 +49,10 @@ module.exports = {
4749
{
4850
test: /\.css$/,
4951
exclude: root('src', 'app'),
50-
loader: ExtractTextPlugin.extract({
51-
fallback: "style-loader",
52-
use: "css-loader"
53-
})
52+
use: [
53+
MiniCssExtractPlugin.loader,
54+
'css-loader'
55+
]
5456
},
5557
{
5658
test: /\.css$/,
@@ -59,29 +61,46 @@ module.exports = {
5961
}
6062
]
6163
},
62-
64+
6365
plugins: [
6466
new CleanWebpackPlugin('build'),
65-
new webpack.optimize.CommonsChunkPlugin({
66-
name: ['app', 'vendor', 'polyfills']
67-
}),
6867
new webpack.ContextReplacementPlugin(
69-
/angular(\\|\/)core(\\|\/)@angular/,
68+
/\@angular(\\|\/)core(\\|\/)f?esm5/,
7069
root('src')
7170
),
7271
new HtmlWebpackPlugin({
7372
template: root('src', 'index.html'),
7473
favicon: root('src', 'favicon.ico')
7574
}),
76-
77-
new ExtractTextPlugin('[name].css')
75+
76+
new MiniCssExtractPlugin({
77+
// Options similar to the same options in webpackOptions.output
78+
// both options are optional
79+
filename: "[name].css",
80+
chunkFilename: "[id].css"
81+
})
7882
],
79-
83+
84+
optimization: {
85+
splitChunks: {
86+
cacheGroups: {
87+
//app: { name: 'app'},
88+
vendor: {
89+
test: /[\\/]node_modules[\\/]/,
90+
chunks: 'initial',
91+
name: 'vendor',
92+
enforce: true
93+
},
94+
//polyfills: { name: 'polyfills'},
95+
}
96+
}
97+
},
98+
8099
devtool: 'source-map'
81100
};
82101

83102

84103

85104
function root(...args) {
86-
return path.join.apply(path, [__dirname].concat(args))
105+
return path.join(__dirname, ...args)
87106
}

0 commit comments

Comments
 (0)