diff --git a/packages/wrenfield/scripts/stage.mjs b/packages/wrenfield/scripts/stage.mjs index 703976d..1db991f 100644 --- a/packages/wrenfield/scripts/stage.mjs +++ b/packages/wrenfield/scripts/stage.mjs @@ -18,7 +18,7 @@ const PUBLIC = [ "models", "data", ]; -const BARE_KIT_IMPORT = /"@excom\/nucleus-kit\//g; +const BARE_KIT_IMPORT = /"@excom\/nucleus-kit\/([^"]+)"/g; const REWRITTEN_FILES = ["index.html", "shell.css"]; export const stage = async ({ @@ -38,7 +38,7 @@ export const stage = async ({ cp(join(root, name), join(out, name), { recursive: true }) ) ); - const cdnPrefix = `"https://unpkg.com/@excom/nucleus-kit@${version}/`; + const cdnBase = `https://unpkg.com/@excom/nucleus-kit@${version}/dist`; let rewrites = 0; for (const file of REWRITTEN_FILES) { const filePath = join(out, file); @@ -46,7 +46,13 @@ export const stage = async ({ const matches = content.match(BARE_KIT_IMPORT); if (matches) { rewrites += matches.length; - await writeFile(filePath, content.replaceAll(BARE_KIT_IMPORT, cdnPrefix)); + await writeFile( + filePath, + content.replaceAll(BARE_KIT_IMPORT, (_, path) => { + const cdnPath = /\.css$/.test(path) ? path : `${path}.min.js`; + return `"${cdnBase}/${cdnPath}"`; + }) + ); } } if (rewrites === 0) diff --git a/packages/wrenfield/shell.css b/packages/wrenfield/shell.css index a557aa7..b48d595 100644 --- a/packages/wrenfield/shell.css +++ b/packages/wrenfield/shell.css @@ -1007,7 +1007,7 @@ label { } } @keyframes wf-skeleton { - to { + from { opacity: 0.45; } } diff --git a/packages/wrenfield/support/tests/stage.test.ts b/packages/wrenfield/support/tests/stage.test.ts index ac28185..f23591b 100644 --- a/packages/wrenfield/support/tests/stage.test.ts +++ b/packages/wrenfield/support/tests/stage.test.ts @@ -36,10 +36,10 @@ describe("stage", () => { expect(await stage({ out })).toBe(version); const html = await read(out, "index.html"); const css = await read(out, "shell.css"); - const htmlPinned = html.match(/unpkg\.com\/@excom\/nucleus-kit@[^/]+\//g); - const cssPinned = css.match(/unpkg\.com\/@excom\/nucleus-kit@[^/]+\//g); - expect(htmlPinned).toEqual([`unpkg.com/@excom/nucleus-kit@${version}/`]); - expect(cssPinned).toEqual([`unpkg.com/@excom/nucleus-kit@${version}/`]); + const htmlPinned = html.match(/unpkg\.com\/@excom\/nucleus-kit@[^/]+\/dist\//g); + const cssPinned = css.match(/unpkg\.com\/@excom\/nucleus-kit@[^/]+\/dist\//g); + expect(htmlPinned).toEqual([`unpkg.com/@excom/nucleus-kit@${version}/dist/`]); + expect(cssPinned).toEqual([`unpkg.com/@excom/nucleus-kit@${version}/dist/`]); }); it("rewrites bare Kit imports and no other line", async () => { @@ -48,13 +48,13 @@ describe("stage", () => { const afterHtml = (await read(out, "index.html")).split("\n"); expect(afterHtml).toHaveLength(beforeHtml.length); expect(afterHtml.filter((line, i) => line !== beforeHtml[i])).toEqual([ - expect.stringContaining("unpkg.com/@excom/nucleus-kit@1.0.0-rc.1/nucleus-kit.progressive"), + expect.stringContaining("unpkg.com/@excom/nucleus-kit@1.0.0-rc.1/dist/nucleus-kit.progressive.min.js"), ]); const beforeCss = (await read(PACKAGE, "shell.css")).split("\n"); const afterCss = (await read(out, "shell.css")).split("\n"); expect(afterCss).toHaveLength(beforeCss.length); expect(afterCss.filter((line, i) => line !== beforeCss[i])).toEqual([ - expect.stringContaining("unpkg.com/@excom/nucleus-kit@1.0.0-rc.1/basic.css"), + expect.stringContaining("unpkg.com/@excom/nucleus-kit@1.0.0-rc.1/dist/basic.css"), ]); });