What is the best way to set the --base-href for ng build by default, but not affect ng serve?
Not directly, but you can define NPM scripts in your package.json:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --base-href=/path"
},
then you run the webpack server with npm start
and can run the build with npm run build
(note: NPM only recognizes some script names like start
, where you can omit run
)
You can also specify different build scripts, mine look like these:
"scripts": {
"ng": "ng",
"start": "ng serve --preserve-symlinks",
"build": "ng build --base-href /static/frontend/ --output-path ../static/frontend --aot",
"build-prod": "ng build --env=prod --prod --output-path dist-prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With