Reputation: 5789
When I deploy a nodeJS app to Dokku via Git, it runs the command:
-----> Build
Running build
> [email protected] build /tmp/build
> ng build
This is an Angular app and I'd like it to build in production mode, ie: ng build --aot --prod
.
How can I affect the command that is run during Dokku's build phase?
Here's the scripts
part of my package.json
:
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
I've tried adding "postinstall": "ng build --aot --prod"
to the above. That does indeed run the right command just after installation, but then the build phase kicks in and it runs ng build
all over again (so overriding the production).
Perhaps I could change "build": "ng build"
above to add --aot --prod
- but I'm not sure what effect that would have when running my Node app locally, where I never want --prod
?
Upvotes: 0
Views: 1133
Reputation: 100
You can run the ng build --aot --prod
in your local machine, then commit the dist folder (remove it from .gitignore).
Then just create an empty file called exactly ".static" on the root folder of the project.
Then on the dokku server run:
dokku config:set yourappname NGINX_ROOT=dist BUILDPACK_URL=https://github.com/dokku/buildpack-nginx
Then run "git push dokku master".
With that approach you won't have to worry about the package.json scripts.
Upvotes: 1