-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create useful defautl for webpack build prod
This change override webpack prod, to do: - Add/Enable cache to reduce build time for subsequenct builds - Remove plugins that are not necessary for prod - Disbale dev-tools i.e. .map files
- Loading branch information
1 parent
8c7767c
commit a7e1941
Showing
3 changed files
with
35 additions
and
2 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
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
29 changes: 29 additions & 0 deletions
29
tutormfe/templates/mfe/build/mfe/webpack.prod.tutor.config.js
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,29 @@ | ||
const { merge } = require('webpack-merge'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const baseProdConfig = ( | ||
fs.existsSync('./webpack.prod.config.js') | ||
? require('./webpack.prod.config.js') | ||
: require('@edx/frontend-build/config/webpack.prod.config.js') | ||
); | ||
|
||
{% if not MFE_REMOVE_WEBPACK_BUILD_CACHE %} | ||
// This shall boost rebuild time for subsequent builds. | ||
// Ref docs: https://webpack.js.org/configuration/cache/#cachecachedirectory | ||
baseProdConfig.cache= { | ||
type: 'filesystem', | ||
cacheDirectory: path.resolve(__dirname,'.cache'), | ||
}, | ||
{% endif %} | ||
|
||
// Disable Unnecessary Plgugins | ||
baseProdConfig.plugins = baseProdConfig.plugins | ||
.filter(plugin => (plugin.constructor.name !== 'NewRelicPlugin')) | ||
.filter(plugin => (plugin.constructor.name !== 'HtmlWebpackNewRelicPlugin')) | ||
.filter(plugin => (plugin.constructor.name !== 'BundleAnalyzerPlugin')); | ||
|
||
// Don't generate/incldue .map files _Reduces dist to ~-70%_ | ||
baseProdConfig.devtool = false; | ||
|
||
module.exports = baseProdConfig; |