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

ensure CSS placeholders are overwritten #462

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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