From 02256ae214ded6263f34aadb3cd21f723fc80e6f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 2 Oct 2018 10:27:02 -0400 Subject: [PATCH] ensure CSS placeholders are overwritten --- src/core/create_compilers/extract_css.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/create_compilers/extract_css.ts b/src/core/create_compilers/extract_css.ts index 6dd615f6d..23b691734 100644 --- a/src/core/create_compilers/extract_css.ts +++ b/src/core/create_compilers/extract_css.ts @@ -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) {