Different webpack.config.js files for different configurations not working with v9.2
See original GitHub issueHello, attempting to implement your recommended angular.json for different webpack configurations per https://github.com/just-jeb/angular-builders/issues/248#issuecomment-466650709
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"outputPath": "dist/electron-angular-native",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.png",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"customWebpackConfig": {
"path": "./prod-webpack.config.js"
},
},
"development": {
"customWebpackConfig": {
"path": "./dev-webpack.config.js"
},
}
}
},
Unfortunately, with v9.20 I can’t get the webpack.config.js files to be picked up unless they’re specified within the top-level options.
I can get it running with dev defaults only:
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./dev-webpack.config.js"
},
"outputPath": "dist/electron-angular-native",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.png",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"customWebpackConfig": {
"path": "./prod-webpack.config.js"
},
},
"development": {
}
}
},
… but then prod-webpack.config.js
is ignored when building with --configuration=production
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to use multiple configuration files in webpack?
There are some ways to accomplish that. Perhaps the simplest one is specifying the config file to use. Read more about webpack usage...
Read more >How to set up different Webpack configurations for ...
Here I'll show you the most straight forward method I've found. First, create 3 files: webpack.config.dev.js : This will be your Webpack config...
Read more >How to Use Multiple Webpack Configurations - YouTube
If you are new to Webpack, you quickly noticed how many configurations it has available. Not only are there too many, but it...
Read more >Configuration - webpack
dev is an online tool for creating custom webpack configurations. It allows you to select various features that will be combined and added...
Read more >All You Need to Know about Webpack in Examples - Medium
You will know how to configure webpack, add assets, add css files, bundle your js file, starting a server, prod and dev build...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, just an update for those who found this after Angular 11.1.0 release: You will probably need to use AngularWebpackPlugin instead of AngularCompilerPlugin.
For example in my case it looks like this:
My problem was that my custom
prod-webpack.config.js
had module rules to try and transform *.html templates as described in this Medium article.This config file was being loaded correctly.
However, if your production config options specify ahead-of-time
aot: true
compilation (which most prod configs for Angular 8+ do) then .html templates don’t get processed the same way they do for just-in-time (JIT) builds which is what you may be using forng serve
.If your issue looks to be related - i.e., your customWebpackConfig is trying to transform .html templates - then this discussion gives some leads that may be worth following up: https://github.com/IAMtheIAM/angular-webpack-nodejs-starter/issues/4