11const webpack = require ( 'webpack' )
2- const ExtractTextPlugin = require ( 'extract-text-webpack -plugin' )
2+ const MiniCssExtractPlugin = require ( 'mini-css-extract -plugin' )
33const UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' )
4+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
5+ const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' )
46// Minify hangs in 92% when build in production, so now we are testing the uglify above
57// const MinifyPlugin = require('babel-minify-webpack-plugin')
68
79module . exports = {
810 mode : 'production' ,
911 optimization : {
1012 minimizer : [ new UglifyJsPlugin ( ) ] ,
13+ runtimeChunk : 'single' ,
14+ splitChunks : {
15+ chunks : 'all' ,
16+ maxInitialRequests : Infinity ,
17+ // minimum chunk size 30KB
18+ minSize : 30000 ,
19+ cacheGroups : {
20+ vendor : {
21+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] ( @ m a t e r i a l - u i ) [ \\ / ] / ,
22+ name : 'vendor'
23+ } ,
24+ } ,
25+ } ,
1126 } ,
1227 entry : './src/index.js' ,
1328 output : {
1429 path : `${ __dirname } /public` ,
15- filename : './app .js'
30+ filename : '[name].[hash] .js'
1631 } ,
1732 resolve : {
1833 extensions : [ '.js' , '.jsx' ] ,
@@ -23,14 +38,24 @@ module.exports = {
2338 } ,
2439 plugins : [
2540 // new MinifyPlugin(),
26- new ExtractTextPlugin ( 'app.css' ) ,
41+ new HtmlWebpackPlugin ( {
42+ filename : `${ __dirname } /public/index.html` ,
43+ template : 'src/index.html' ,
44+ chunksSortMode : 'none'
45+ } ) ,
46+ new MiniCssExtractPlugin ( {
47+ filename : 'app.css'
48+ } ) ,
2749 new webpack . DefinePlugin ( {
2850 'process.env' : {
2951 'NODE_ENV' : JSON . stringify ( 'production' ) ,
3052 'API_HOST' : JSON . stringify ( process . env . API_HOST ) ,
3153 'STRIPE_PUBKEY' : JSON . stringify ( process . env . STRIPE_PUBKEY ) ,
3254 'SLACK_CHANNEL_INVITE_LINK' : JSON . stringify ( process . env . SLACK_CHANNEL_INVITE_LINK )
3355 }
56+ } ) ,
57+ new CleanWebpackPlugin ( {
58+ cleanOnceBeforeBuildPatterns : [ '!favicon-gitpay.ico' ]
3459 } )
3560 ] ,
3661 module : {
@@ -39,12 +64,12 @@ module.exports = {
3964 loader : 'babel-loader' ,
4065 exclude : / n o d e _ m o d u l e s / ,
4166 query : {
42- presets : [ 'es2015' , 'react' ] ,
67+ presets : [ [ 'es2015' , { 'modules' : false } ] , 'react' ] ,
4368 plugins : [ 'transform-object-rest-spread' , 'transform-class-properties' ]
4469 }
4570 } , {
4671 test : / \. c s s $ / ,
47- loader : ExtractTextPlugin . extract ( { fallback : 'style- loader' , use : 'css-loader' } )
72+ use : [ MiniCssExtractPlugin . loader , 'css-loader' ]
4873 } , {
4974 test : / \. ( w o f f | w o f f 2 | t t f | e o t | s v g ) $ / ,
5075 loader : 'file-loader'
0 commit comments