Overview
The project uses Rollup to bundle JavaScript modules and compile SCSS stylesheets. Assets are built fromapp/assets/ and output to app/static/.
Quick Start
Build Assets Once
Watch for Changes
Build Configuration
Rollup configuration is defined inrollup.config.mjs with two build targets:
1. JavaScript Build
Input:app/assets/javascripts/main.mjsOutput:
app/static/javascripts/main.js
Features:
- ES module compilation
- Module resolution with
@rollup/plugin-node-resolve - Minification with
@rollup/plugin-terser - Source maps enabled
2. SCSS Build
Input:app/assets/stylesheets/main.scssOutput:
app/static/stylesheets/main.css
Features:
- Sass compilation
- CSS minification
- Source maps enabled
- Include paths:
node_modules/govuk-frontend/dist/govuk/node_modules/
Static Asset Copying
The build process copies static assets toapp/static/:
- Images:
app/assets/images/**/*→app/static/images/ - GOV.UK Frontend Images: →
app/static/images/ - GOV.UK Frontend Fonts: →
app/static/fonts/ - Manifest:
govuk-frontendmanifest →app/static/
Directory Structure
Dependencies
Production
- govuk-frontend 6.0.0 - GOV.UK Design System components and styles
Development
- rollup - Module bundler
- @rollup/plugin-node-resolve - Resolve node_modules imports
- @rollup/plugin-terser - JavaScript minification
- rollup-plugin-copy - Copy static assets
- rollup-plugin-styler - SCSS compilation
- sass - Sass compiler
Bootstrap
Initial setup including installing dependencies and building assets:- Generate version file
- Install Python dependencies from
requirements_for_test.txt npm ci --no-audit- Install npm dependenciesnpm rebuild node-sass- Rebuild native dependenciesnpm run build- Build frontend assets
Sass Configuration
The Sass compiler is configured with:- Include paths: Access to GOV.UK Frontend and node_modules
- Deprecation silencing: Suppresses warnings for:
mixed-declsglobal-builtincolor-functionsslash-divimport
Development Workflow
-
Start watch mode:
-
Make changes to files in
app/assets/ -
Assets rebuild automatically to
app/static/ - Refresh browser to see changes (or use live reload if configured)
Production Build
For production deployment:Troubleshooting
Assets not updating
If assets don’t update after changes:- Check that watch mode is running
- Verify file paths in
rollup.config.mjs - Clear browser cache
- Restart the watch process
Build errors
If you encounter build errors:Missing GOV.UK Frontend assets
Ensure GOV.UK Frontend is installed:node_modules/govuk-frontend/.