-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Intro
We dearly need a lightweight way to customize the internal webpack config file, so advanced users can tweak it, and still use the CLI, without having to eject. The current approach of having to eject causes a huge amount of overhead (also for the CLI team it seems). In NG5, we personally had 4 different fully complete webpack config files, to satisfy our dev environment, which was getting out of hand.
Since you can't eject in NG6, you currently have people rewriting node_modules
files, to do some simple customizations. See https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d
Proposal
Doing an ng serve/whatever
calls a hook file, where you can customize the webpack config related to the current ng
command.
function webpackHook(config) {
config.node = {
crypto: true,
}
const args = require('yargs').argv;
if (args.stats) {
try {
console.log('Adding Stats Plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
config.plugins.push(new BundleAnalyzerPlugin());
} catch (e) {
console.error('webpack-bundle-analyzer not installed - `npm i webpack-bundle-analyzer --save-dev`');
}
}
return config;
}
A hook file like this would probably remove the need to eject in the first place.
Was originally posted here, where it seemed to gather support: #1548 (comment)