File tree 2 files changed +21
-4
lines changed
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,26 @@ export class BasePlugin {
75
75
htmlFileName : string
76
76
style : string
77
77
} ) {
78
- const styleString = this . config . noStyleTag
79
- ? style
80
- : `<style type="text/css">${ style } </style>`
78
+ let attributesString = ''
79
+
80
+ if ( this . config . attributes ) {
81
+ if (
82
+ typeof this . config . attributes !== 'object' &&
83
+ this . config . attributes === null
84
+ ) {
85
+ throw new Error (
86
+ `Please provide a key/value object if intending to use the attributes option` ,
87
+ )
88
+ }
89
+
90
+ Object . keys ( this . config . attributes ) . map ( ( key ) => {
91
+ const value = this . config . attributes [ key ] || ''
92
+ attributesString += ` ${ key } ="${ value } "`
93
+ } )
94
+ }
95
+
96
+ const styleString = `<style${ attributesString } >${ style } </style>`
97
+
81
98
const replaceValues = [ styleString , this . replaceConfig . target ]
82
99
83
100
if ( this . replaceConfig . position === 'after' ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export interface Config {
14
14
filter ?( fileName : string ) : boolean
15
15
leaveCSSFile ?: boolean
16
16
replace ?: ReplaceConfig
17
- noStyleTag ?: boolean
17
+ attributes ?: any
18
18
}
19
19
20
20
export interface FileCache {
You can’t perform that action at this time.
0 commit comments