Skip to content

Commit

Permalink
ensure %svelte.head% and %svelte.body% are replaced last
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 21, 2022
1 parent 1bce8e9 commit 1f6783d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/kit/src/core/dev/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ export async function create_plugin(config, cwd) {
target: config.kit.target,
template: ({ head, body, assets }) => {
let rendered = load_template(cwd, config)
.replace(/%svelte\.assets%/g, assets)
// head and body must be replaced last, in case someone tries to sneak in %svelte.assets% etc
.replace('%svelte.head%', () => head)
.replace('%svelte.body%', () => body)
.replace(/%svelte\.assets%/g, assets);
.replace('%svelte.body%', () => body);

if (amp) {
const result = amp.validateString(rendered);
Expand Down

0 comments on commit 1f6783d

Please sign in to comment.