Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #462 from sveltejs/overwrite-css-placeholders
Browse files Browse the repository at this point in the history
ensure CSS placeholders are overwritten
  • Loading branch information
Rich-Harris authored Oct 2, 2018
2 parents e2d325e + 02256ae commit 472c0c1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/create_compilers/extract_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,15 @@ export default function extract_css(client_result: CompileResult, components: Pa
result.chunks[component.file] = files;
});

const replaced = entry.replace(/["']__SAPPER_CSS_PLACEHOLDER:(.+?)__["']/g, (m, route) => {
return JSON.stringify(replacements.get(route));
});
fs.readdirSync(`${dirs.dest}/client`).forEach(file => {
const source = fs.readFileSync(`${dirs.dest}/client/${file}`, 'utf-8');

const replaced = source.replace(/["']__SAPPER_CSS_PLACEHOLDER:(.+?)__["']/g, (m, route) => {
return JSON.stringify(replacements.get(route));
});

fs.writeFileSync(`${dirs.dest}/client/${main}`, replaced);
fs.writeFileSync(`${dirs.dest}/client/${file}`, replaced);
});

const leftover = get_css_from_modules(Array.from(unaccounted_for));
if (leftover) {
Expand Down

0 comments on commit 472c0c1

Please sign in to comment.