Reputation: 174
What is the best way to set the --base-href for ng build by default, but not affect ng serve?
Upvotes: 6
Views: 6534
Reputation: 3038
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"
},
Upvotes: 5