From 356ee9a541bf58b7189c09d7b9070b926be24c3c Mon Sep 17 00:00:00 2001 From: Tristan Brookes Date: Wed, 16 Jan 2019 14:36:14 +0000 Subject: [PATCH 1/2] Feat: add option to not delete CSS file --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 303e94e..1662d0f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,8 @@ interface Compilation { interface ReplaceConfig { position?: 'before' | 'after' removeTarget?: boolean - target: string + target: string, + leaveCssFile?: boolean } interface Config { @@ -71,13 +72,16 @@ export default class Plugin private prepare({ assets }: Compilation) { const isCSS = is('css'); const isHTML = is('html'); + const { replace: replaceConfig = DEFAULT_REPLACE_CONFIG } = this.config; Object.keys(assets).forEach((fileName) => { if (isCSS(fileName)) { const isCurrentFileNeedsToBeInlined = this.filter(fileName); if (isCurrentFileNeedsToBeInlined) { this.css[fileName] = assets[fileName].source(); - delete assets[fileName]; + if (!replaceConfig.leaveCssFile) { + delete assets[fileName] + } } } else if (isHTML(fileName)) { this.html[fileName] = assets[fileName].source(); From 39cb00b98af942ad10e34057f70b3ef91e53f4ab Mon Sep 17 00:00:00 2001 From: Tristan Brookes Date: Wed, 16 Jan 2019 14:37:33 +0000 Subject: [PATCH 2/2] Update: Readme with leaveCssFile --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f45c1c8..a40c80a 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ interface Config { target: string position?: 'before' | 'after' removeTarget?: boolean + leaveCssFile?: boolean } } ``` @@ -83,6 +84,7 @@ replace?: { target: string position?: 'before' | 'after' // default is 'before' removeTarget?: boolean // default is false + leaveCssFile?: boolean // default is false } ``` A config for customizing the location of injection, default will add internal style sheet before the `` @@ -92,6 +94,8 @@ A target for adding the internal style sheet Add internal style sheet `before`/`after` the `target` #### removeTarget(optional) if `true`, it will remove the `target` from the output HTML +#### leaveCssFile(optional) +if `true`, it will leave CSS files where they are when inlining ##### example ```html