Skip to content

Commit

Permalink
build(demo,lib): Update deps, use webpack4
Browse files Browse the repository at this point in the history
Due to webpack-contrib/mini-css-extract-plugin#257, mini-css-extract-plugin@0.4.2 should be avoided. I expect next version to fix this issue.
  • Loading branch information
Gerkin committed Sep 10, 2018
1 parent 95c4565 commit 0475085
Show file tree
Hide file tree
Showing 5 changed files with 21,048 additions and 1,902 deletions.
63 changes: 41 additions & 22 deletions demo/webpack.config.js
@@ -1,26 +1,28 @@
var webpack = require('webpack'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
path = require('path');
const webpack = require('webpack'),
CleanWebpackPlugin = require('clean-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
MiniCssExtractPlugin = require('mini-css-extract-plugin');
path = require('path');

module.exports = {
mode: 'production',

entry: {
'polyfills': root('src', 'polyfills.ts'),
'vendor': root('src', 'vendor.ts'),
'app': root('src', 'main.ts')
},

output: {
path: root('build'),
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},

resolve: {
extensions: ['.ts', '.js']
},

devServer: {
historyApiFallback: true,
stats: 'minimal',
Expand All @@ -29,7 +31,7 @@ module.exports = {
inline: true,
openPage: ''
},

module: {
rules: [
{
Expand All @@ -47,10 +49,10 @@ module.exports = {
{
test: /\.css$/,
exclude: root('src', 'app'),
loader: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
test: /\.css$/,
Expand All @@ -59,29 +61,46 @@ module.exports = {
}
]
},

plugins: [
new CleanWebpackPlugin('build'),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
/\@angular(\\|\/)core(\\|\/)f?esm5/,
root('src')
),
new HtmlWebpackPlugin({
template: root('src', 'index.html'),
favicon: root('src', 'favicon.ico')
}),

new ExtractTextPlugin('[name].css')

new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
})
],


optimization: {
splitChunks: {
cacheGroups: {
//app: { name: 'app'},
vendor: {
test: /[\\/]node_modules[\\/]/,
chunks: 'initial',
name: 'vendor',
enforce: true
},
//polyfills: { name: 'polyfills'},
}
}
},

devtool: 'source-map'
};



function root(...args) {
return path.join.apply(path, [__dirname].concat(args))
return path.join(__dirname, ...args)
}

0 comments on commit 0475085

Please sign in to comment.