diff --git a/src/core/base-plugin.ts b/src/core/base-plugin.ts index 6deda5d..3265f31 100644 --- a/src/core/base-plugin.ts +++ b/src/core/base-plugin.ts @@ -21,11 +21,13 @@ export class BasePlugin { protected prepare({ assets }: Compilation) { Object.keys(assets).forEach((fileName) => { - if (isCSS(fileName) && this.isCurrentFileNeedsToBeInlined(fileName)) { - this.cssStyleCache[fileName] = assets[fileName].source() + if (isCSS(fileName) && !this.isCurrentFileNeedsToBeLinked(fileName)) { + if (isCSS(fileName) && this.isCurrentFileNeedsToBeInlined(fileName)) { + this.cssStyleCache[fileName] = assets[fileName].source() - if (!this.config.leaveCSSFile) { - delete assets[fileName] + if (!this.config.leaveCSSFile) { + delete assets[fileName] + } } } }) @@ -66,6 +68,14 @@ export class BasePlugin { } } + protected isCurrentFileNeedsToBeLinked(fileName: string): boolean { + if (typeof this.config.ignore === 'function') { + return this.config.ignore(fileName) + } else { + return true + } + } + protected addStyle({ html, htmlFileName, diff --git a/src/types.ts b/src/types.ts index 4b9660e..fea1d71 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,6 +12,7 @@ export const DEFAULT_REPLACE_CONFIG: ReplaceConfig = { export interface Config { filter?(fileName: string): boolean + ignore?(fileName: string): boolean leaveCSSFile?: boolean replace?: ReplaceConfig }