Skip to content

Commit

Permalink
fix: prevent loading client side scripts when in ssr-only mode (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu authored Dec 18, 2023
1 parent 93ce7bb commit 7b70ade
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default fp(
base: assetBase,
development,
prefix,
mode,
});
await f.register(importElementPn, {
appName: name,
Expand Down
24 changes: 24 additions & 0 deletions test/lib/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,30 @@ test('hydrate: production mode does not include lit-element-hydrate-support as a
await app.close();
});

test('ssr: production mode does not include content script in page', async (t) => {
const app = fastify({ logger: false });
const config = await setupConfig();
config.set('app.mode', 'ssr-only');
config.set('app.development', false);

await app.register(plugin, {
cwd: tmp,
config,
});

const address = await app.listen({ port: 0 });
const manifest = await fetch(`${address}/manifest.json`);
const text = await manifest.text();
console.log(text)
t.equal(manifest.status, 200, 'manifest file should be sucessfully served');
t.notMatch(
text,
'/static/client/content.js',
'should not contain content script tag',
);
await app.close();
});

// // test("build plugin", async (t) => {})
// // test("locale", async (t) => {})
// // test("metrics", async (t) => {})
Expand Down

0 comments on commit 7b70ade

Please sign in to comment.