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 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();