An official website of the United States government US flag signifying that this is a United States federal government website

Building static assets

Building static assets

Applications with non-trivial static assets (Javascript and CSS files) often include a build step to bundle and minify files.

Build assets on CI

For applications deployed from a continuous integration service, building assets on CI is a natural fit. Before deploying to, the CI service runs the asset build process. Then the compiled assets are pushed to along with the application code. Here’s a minimal example for Travis CI:

# .travis.yml
  provider: script
  skip_cleanup: true
  script: ./
# ./
npm run dist
cf push -f manifest.yml

If static assets are hosted on a CDN, the CI service can be configured to upload compiled assets to the CDN instead of pushing to

This approach avoids the need to use multiple or custom buildpacks.

Examples in the wild:

Build assets on

If the application and build process are implemented in the same language, assets can be built directly on on application start. Here’s a minimal example for a node.js application:

# manifest.yml
command: npm run build && node app.js