From 8fc1f90bfc344e1f9a1b8c1de1a798e43bfeb47f Mon Sep 17 00:00:00 2001 From: Evert van Brussel Date: Thu, 9 Jul 2020 14:09:13 +0200 Subject: [PATCH 1/2] Fix #699 when importing css using postcss --- src/core/create_compilers/RollupCompiler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/create_compilers/RollupCompiler.ts b/src/core/create_compilers/RollupCompiler.ts index 65fa20e7b..4df6d822e 100644 --- a/src/core/create_compilers/RollupCompiler.ts +++ b/src/core/create_compilers/RollupCompiler.ts @@ -39,9 +39,11 @@ export default class RollupCompiler { this.chunks.push(chunk); }, transform: (code: string, id: string) => { - if (/\.css$/.test(id)) { + if (/\.css$/.test(id) && !/styleInject/.test(code)) { this.css_files.push({ id, code }); return ``; + } else if (/styleInject/.test(code)) { + return code; } } }); From 60a299b9c0a2cb6cc6db1f6414dd3099cd8b130b Mon Sep 17 00:00:00 2001 From: Evert van Brussel Date: Thu, 9 Jul 2020 14:26:31 +0200 Subject: [PATCH 2/2] #699, slightly more bug-proof --- src/core/create_compilers/RollupCompiler.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/create_compilers/RollupCompiler.ts b/src/core/create_compilers/RollupCompiler.ts index 4df6d822e..f953760b0 100644 --- a/src/core/create_compilers/RollupCompiler.ts +++ b/src/core/create_compilers/RollupCompiler.ts @@ -39,12 +39,14 @@ export default class RollupCompiler { this.chunks.push(chunk); }, transform: (code: string, id: string) => { - if (/\.css$/.test(id) && !/styleInject/.test(code)) { - this.css_files.push({ id, code }); - return ``; - } else if (/styleInject/.test(code)) { + if (!/\.css$/.test(id)) return; + + if (/styleInject/.test(code)) { return code; } + + this.css_files.push({ id, code }); + return ``; } });