govuk-prototype-kit icon indicating copy to clipboard operation
govuk-prototype-kit copied to clipboard

Support assets compilation at build time

Open smeny opened this issue 2 years ago • 2 comments

Context

We have a prototype hosted with AWS ECS and we followed the instructions to publish it in “production” mode (https://prototype-kit.service.gov.uk/docs/publishing). We are trying to keep resources to a minimum but we noticed that assets are compiled each time the container starts which delays the startup getting our container CPU to 100%.

We think compilation is done here but we couldn't find a way to call this function directly from our prototype.

We suggest implementing a call such as "npm run compile-assets" to be able to compile assets when a docker image is built.

Alternatives

Compile assets at runtime

Additional information (if applicable)

I would say this feature fits into several objectives of reducing processing time such as carbon-neutral initiatives or point 12 of the technology code of practice, aiming to make technology sustainable.

Thank you!

smeny avatar Sep 19 '23 07:09 smeny

This sounds like it’d be something worth investigating to me! 👍

The Heroku documentation for Node.js apps suggests that it will run npm run build automatically before compiling the slug.

If the CSS and javascript assets were compiled by a build step, the source assets themselves could perhaps get added to the .slugignore file, so that the overall slug size is reduced a bit (which can help speed up deploys). That said, most of the CSS and javascript source code is within the govuk-frontend npm package, and that'd still be needed at runtime for all of the macros, so it might not be a huge saving?

frankieroberto avatar Sep 19 '23 09:09 frankieroberto

The govuk-frontend package has several build scripts that could be invoked. I have been trying to invoke them via npx but without success so far.

smeny avatar Sep 19 '23 16:09 smeny