Skip to content

Commit 4328dda

Browse files
try again to fix asset paths in distribution
1 parent 9958d65 commit 4328dda

27 files changed

+52
-125
lines changed

package-lock.json

Lines changed: 1 addition & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
"dev": "vite dev",
1616
"build": "vite build && npm run package",
1717
"preview": "vite preview",
18-
"prepackage": "tsx scripts/generate-index.ts",
18+
"prepackage": "tsx scripts/generate-index.ts && node scripts/copy-static-assets.js && npm run copy-govuk-assets",
1919
"package": "npm run prepackage && svelte-kit sync && svelte-package && publint",
2020
"prepublishOnly": "npm run package",
2121
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
2222
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
2323
"lint": "eslint . && prettier --check .",
2424
"format": "prettier --write .",
2525
"generate-data": "tsx scripts/generateJSONData.cjs",
26+
"copy-static-assets": "node scripts/copy-static-assets.js",
2627
"copy-govuk-assets": "node scripts/copy-govuk-assets.js",
2728
"prepare": "npm run copy-govuk-assets",
2829
"create-component-and-wrapper-pages": "node scripts/create-component-and-wrapper-pages.js"
@@ -77,8 +78,7 @@
7778
"tsx": "^4.19.2",
7879
"typescript": "^5.0.0",
7980
"typescript-eslint": "^8.0.0",
80-
"vite": "^5.0.11",
81-
"vite-plugin-static-copy": "^2.3.1"
81+
"vite": "^5.0.11"
8282
},
8383
"dependencies": {
8484
"@dwp/dwp-frontend": "^3.3.0",

scripts/copy-govuk-assets.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ const __filename = fileURLToPath(import.meta.url);
1010
const __dirname = dirname(__filename);
1111
const projectRoot = join(__dirname, "..");
1212

13-
// Add components directory
13+
// Add components directory and new static assets directory
1414
const dirs = [
1515
join(projectRoot, "static/assets"),
1616
join(projectRoot, "static/assets/images"),
1717
join(projectRoot, "static/assets/fonts"),
1818
join(projectRoot, "static/css"),
1919
join(projectRoot, "static/js"),
2020
join(projectRoot, "src/lib/components/js/components"),
21+
join(projectRoot, "src/lib/static/assets/css"), // Add new CSS destination
2122
];
2223

2324
dirs.forEach((dir) => {
@@ -71,7 +72,7 @@ const govukCssDestStatic = join(
7172
);
7273
const govukCssDestLib = join(
7374
projectRoot,
74-
"src/lib/styles/vendor/govuk-frontend.min.css",
75+
"src/lib/static/assets/css/govuk-frontend.min.css",
7576
);
7677

7778
if (fs.existsSync(govukCssSrc)) {
@@ -93,7 +94,7 @@ const mojCssSrc = join(mojPath, "moj/moj-frontend.min.css");
9394
const mojCssDestStatic = join(projectRoot, "static/css/moj-frontend.min.css");
9495
const mojCssDestLib = join(
9596
projectRoot,
96-
"src/lib/styles/vendor/moj-frontend.min.css",
97+
"src/lib/static/assets/css/moj-frontend.min.css",
9798
);
9899

99100
if (fs.existsSync(mojCssSrc)) {

scripts/copy-static-assets.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fs from "fs-extra";
2+
import { join } from "node:path";
3+
4+
const projectRoot = join(process.cwd()); // Assumes script run from project root
5+
6+
const staticDir = join(projectRoot, "static/assets");
7+
const libDestDir = join(projectRoot, "src/lib/static/assets");
8+
9+
const assetsToCopy = ["fonts", "images", "govuk_publishing_components"];
10+
11+
console.log("Copying static assets to src/lib/static/assets...");
12+
13+
// Ensure the base destination directory exists
14+
fs.ensureDirSync(libDestDir);
15+
console.log(`Ensured directory exists: ${libDestDir}`);
16+
17+
assetsToCopy.forEach((assetType) => {
18+
const sourcePath = join(staticDir, assetType);
19+
const destPath = join(libDestDir, assetType);
20+
21+
if (fs.existsSync(sourcePath)) {
22+
try {
23+
fs.copySync(sourcePath, destPath, { overwrite: true });
24+
console.log(`Copied ${sourcePath} to ${destPath}`);
25+
} catch (err) {
26+
console.error(`Error copying ${assetType}:`, err);
27+
}
28+
} else {
29+
console.warn(`Source directory not found, skipping: ${sourcePath}`);
30+
}
31+
});
32+
33+
console.log("Static assets copy process completed!");

src/lib/components_base.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@import "./styles/vendor/moj-frontend.min.css";
2-
@import "./styles/vendor/govuk-frontend.min.css";
1+
@import "./static/assets/css/moj-frontend.min.css";
2+
@import "./static/assets/css/govuk-frontend.min.css";

src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// this file is auto-generated — do not edit by hand
2-
import "$lib/app.css";
2+
import "$lib/components_base.css";
33

44
export { default as InsetText } from './components/content/InsetText.svelte';
55
export { default as WarningText } from './components/content/WarningText.svelte';
File renamed without changes.
File renamed without changes.
39.9 KB
Binary file not shown.
30.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)