Skip to content

Commit

Permalink
Merge pull request #49 from DEFRA/TGC-468-fix-assets-not-loading
Browse files Browse the repository at this point in the history
fix asset loading
  • Loading branch information
swdpcomputing authored Nov 4, 2024
2 parents 0c5b909 + 3b496c2 commit cdd652d
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,5 @@ test-output
# Ignore husky
.husky/_

# Ignore public folder
public/stylesheets/*.css*

# Ignore nginx local logs
nginx_logs/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EXPOSE ${PORT} ${PORT_DEBUG}

COPY package*.json /home/node
RUN NODE_ENV=development npm --ignore-scripts ci
COPY ./build.js /home/node/build.js
COPY ./src /home/node/src
COPY ./test /home/node/test
COPY .eslintrc /home/node/.eslintrc
Expand Down
26 changes: 26 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import fs from 'fs-extra';
import path from 'path';
import { exec } from 'child_process';

const govukPath = 'node_modules/govuk-frontend/dist/govuk/assets';
const publicPath = 'public/assets';

fs.ensureDirSync(publicPath);
fs.copySync(path.join(govukPath, 'fonts'), path.join(publicPath, 'fonts'), { overwrite: true });
fs.copySync(path.join(govukPath, 'images'), path.join(publicPath, 'images'), { overwrite: true });

exec(
'sass --quiet-deps -I node_modules src/main.scss public/stylesheets/main.css',
{ stdio: 'inherit' },
(error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
return;
}
console.log('Build completed successfully');
}
);
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ffc-grants-eligibility-checker",
"description": "FFC Grant Eligibility Checker",
"version": "1.0.19",
"version": "1.0.20",
"license": "OGL-UK-3.0",
"contributors": [
"Andrew Folga <[email protected]>",
Expand All @@ -17,7 +17,8 @@
"lint": "eslint \"./**/*.js\" --cache --cache-strategy content --fix",
"format": "prettier --write \"**/*.js\"",
"format:njk": "prettier --write \"**/*.njk\" --ignore-path .prettierignore",
"build": "sass -I node_modules src/main.scss public/stylesheets/main.css",
"build": "node build.js",
"install": "npm --ignore-scripts i",
"start": "npm run build && nodemon ./src/index.js",
"start:docker": "docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up --build",
"prepare": "husky install",
Expand All @@ -36,6 +37,7 @@
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jsdoc": "^50.2.3",
"eslint-plugin-prettier": "^5.2.1",
"fs-extra": "^11.2.0",
"husky": "^9.1.6",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
Expand Down
2 changes: 2 additions & 0 deletions public/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions public/stylesheets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
1 change: 0 additions & 1 deletion public/stylesheets/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/config/machines/example-grant-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const actionImplementations = {
};

export const exampleGrantMachine = createMachine({
/** @xstate-layout N4IgpgJg5mDOIC5RgB4EMC2AHANmA4gE5oB2ALgLJoDGAFgJYlgB0sZahZAxAHICiADQAqAbQAMAXUSgsAe1j0y9WSWkgUiAIwBmAKzMAbNoBMADk0GAnJbGmALA+MAaEAE8tAdgPNdH02MsvQJtdbVMAX3CXVExcAmJyKjpGFmpZDAwVAFo0gFdyQlcuACEAQQBhAGlxKSQQOQUlFTUNBB1vW1NQ2zFdMQ9jOxd3BHNmE2MbHT1NTTNI6PRsPCJSShoGJmY0jOy8gqL+YRq1BsVlVTrW3WN9A3sbLv87D2thz0tmf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zzdHXWbE45U+5M75zAAZow0Dh6yuN202YYDCSwmMV4Bm7NNbGYBw9wcOx7H+OxLXCIA */
id: 'exampleGrantMachine',
predictableActionArguments: true,
initial: 'start',
Expand Down
2 changes: 1 addition & 1 deletion src/main.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@use "govuk-frontend/dist/govuk/all";
@use "govuk-frontend/dist/govuk/all" with ($govuk-assets-path: "/eligibility-checker/assets/");

0 comments on commit cdd652d

Please sign in to comment.