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

Commit

Permalink
ensure CSS placeholders are overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Oct 2, 2018
1 parent e2d325e commit 02256ae
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 02256ae

Please sign in to comment.