File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ interface Config {
5757 target: string
5858 position? : ' before' | ' after'
5959 removeTarget? : boolean
60+ leaveCssFile? : boolean
6061 }
6162}
6263```
@@ -83,6 +84,7 @@ replace?: {
8384 target: string
8485 position? : ' before' | ' after' // default is 'before'
8586 removeTarget? : boolean // default is false
87+ leaveCssFile? : boolean // default is false
8688}
8789` ` `
8890A config for customizing the location of injection, default will add internal style sheet before the ` </head >`
@@ -92,6 +94,8 @@ A target for adding the internal style sheet
9294Add internal style sheet ` before ` / ` after ` the ` target `
9395#### removeTarget(optional)
9496if ` true ` , it will remove the ` target ` from the output HTML
97+ #### leaveCssFile(optional)
98+ if ` true ` , it will leave CSS files where they are when inlining
9599
96100##### example
97101` ` ` html
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ interface Compilation {
1616interface ReplaceConfig {
1717 position ?: 'before' | 'after'
1818 removeTarget ?: boolean
19- target : string
19+ target : string ,
20+ leaveCssFile ?: boolean
2021}
2122
2223interface Config {
@@ -71,13 +72,16 @@ export default class Plugin
7172 private prepare ( { assets } : Compilation ) {
7273 const isCSS = is ( 'css' ) ;
7374 const isHTML = is ( 'html' ) ;
75+ const { replace : replaceConfig = DEFAULT_REPLACE_CONFIG } = this . config ;
7476
7577 Object . keys ( assets ) . forEach ( ( fileName ) => {
7678 if ( isCSS ( fileName ) ) {
7779 const isCurrentFileNeedsToBeInlined = this . filter ( fileName ) ;
7880 if ( isCurrentFileNeedsToBeInlined ) {
7981 this . css [ fileName ] = assets [ fileName ] . source ( ) ;
80- delete assets [ fileName ] ;
82+ if ( ! replaceConfig . leaveCssFile ) {
83+ delete assets [ fileName ]
84+ }
8185 }
8286 } else if ( isHTML ( fileName ) ) {
8387 this . html [ fileName ] = assets [ fileName ] . source ( ) ;
You can’t perform that action at this time.
0 commit comments