-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configured “webpack-bundle-analyzer”
- Loading branch information
1 parent
dbe7a94
commit 9613033
Showing
7 changed files
with
210 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,5 @@ bower_components | |
node_modules | ||
dist | ||
releases | ||
webpack.report.main.html | ||
webpack.report.renderer.html |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
/* IMPORT */ | ||
|
||
const {BundleAnalyzerPlugin} = require ( 'webpack-bundle-analyzer' ), | ||
ExcludeAssetsPlugin = require ( 'webpack-exclude-assets-plugin' ), | ||
TerserPlugin = require ( 'terser-webpack-plugin' ), | ||
TSConfigPathsPlugin = require ( 'tsconfig-paths-webpack-plugin' ), | ||
path = require ( 'path' ), | ||
webpack = require ( 'webpack' ); | ||
|
||
/* PLUGINS */ | ||
|
||
function PluginSkeletonOptimization ( compiler ) { // Loading heavy resources after the skeleton | ||
compiler.plugin ( 'compilation', compilation => { | ||
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing = { | ||
async promise ( data ) { | ||
data.html = data.html.replace ( /<link(.*?)rel="stylesheet">(.*?)<body>(.*?)<script/, '$2<body>$3<link$1rel="stylesheet"><script' ); // Moving the main CSS to the bottom in order to make the skeleton load faster | ||
return data; | ||
} | ||
}; | ||
}); | ||
} | ||
|
||
/* BASE */ | ||
|
||
function base ( options ) { //TODO: Maybe we don't need to define multiple webpack configs //URL: https://github.com/electron-userland/electron-webpack/issues/290 | ||
|
||
return { | ||
resolve: { | ||
alias: { | ||
'react-dom': process.env.NODE_ENV !== 'production' ? '@hot-loader/react-dom' : 'react-dom' | ||
}, | ||
plugins: [ | ||
new TSConfigPathsPlugin () | ||
] | ||
}, | ||
plugins: [ | ||
new ExcludeAssetsPlugin ({ | ||
path: [ | ||
'\.(eot|ttf|woff)$' // Unused font formats | ||
] | ||
}), | ||
new webpack.DefinePlugin ({ | ||
'Environment.isDevelopment': JSON.stringify ( process.env.NODE_ENV !== 'production' ) | ||
}), | ||
PluginSkeletonOptimization, | ||
new BundleAnalyzerPlugin ({ | ||
analyzerMode: 'static', | ||
reportFilename: path.join ( __dirname, `webpack.report.${options.target}.html` ), | ||
openAnalyzer: false, | ||
logLevel: 'silent' | ||
}) | ||
], | ||
optimization: { | ||
minimizer: [ | ||
new TerserPlugin ({ | ||
parallel: true, | ||
sourceMap: true, | ||
terserOptions: { | ||
keep_fnames: true | ||
} | ||
}) | ||
] | ||
} | ||
}; | ||
|
||
} | ||
|
||
/* EXPORT */ | ||
|
||
module.exports = base; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
/* IMPORT */ | ||
|
||
const base = require ( './webpack.base' ); | ||
|
||
/* CONFIG */ | ||
|
||
const config = base ({ target: 'main' }); | ||
|
||
/* EXPORT */ | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
/* IMPORT */ | ||
|
||
const base = require ( './webpack.base' ); | ||
|
||
/* CONFIG */ | ||
|
||
const config = base ({ target: 'renderer' }); | ||
|
||
/* EXPORT */ | ||
|
||
module.exports = config; |