File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " rollup-plugin-import-css" ,
33 "type" : " module" ,
4- "version" : " 4.1.0 " ,
4+ "version" : " 4.1.1 " ,
55 "description" : " A Rollup plugin to import CSS into JavaScript" ,
66 "main" : " dist/plugin.cjs" ,
77 "module" : " dist/plugin.js" ,
Original file line number Diff line number Diff line change @@ -146,10 +146,13 @@ export default (options = {}) => {
146146 return ;
147147 }
148148
149+ /* create a copy of the styles object that we can modify to avoid caching problems in watch mode */
150+ const stylesToEmit = Object . assign ( { } , styles ) ;
151+
149152 /* copy relative assets to the output directory and update the referenced path */
150153 if ( copyRelativeAssets ) {
151154 for ( let id of stylesheets ) {
152- const assets = [ ...styles [ id ] . matchAll ( / u r l \( \s * ( [ ' " ] ? ) ( \. \/ .* ?) \1\s * \) / g) ] . map ( ( match ) => match [ 2 ] ) ;
155+ const assets = [ ...stylesToEmit [ id ] . matchAll ( / u r l \( \s * ( [ ' " ] ? ) ( \. \/ .* ?) \1\s * \) / g) ] . map ( ( match ) => match [ 2 ] ) ;
153156
154157 for ( let asset of assets ) {
155158 const reference = this . emitFile ( {
@@ -158,13 +161,13 @@ export default (options = {}) => {
158161 source : fs . readFileSync ( path . resolve ( path . dirname ( id ) , asset ) )
159162 } ) ;
160163
161- styles [ id ] = styles [ id ] . replace ( asset , `./${ this . getFileName ( reference ) } ` ) ;
164+ stylesToEmit [ id ] = styles [ id ] . replace ( asset , `./${ this . getFileName ( reference ) } ` ) ;
162165 }
163166 }
164167 }
165168
166169 /* merge all css files into a single stylesheet */
167- const css = stylesheets . map ( ( id ) => styles [ id ] ) . join ( options . minify ? "" : "\n" ) ;
170+ const css = stylesheets . map ( ( id ) => stylesToEmit [ id ] ) . join ( options . minify ? "" : "\n" ) ;
168171
169172 if ( css . trim ( ) . length <= 0 && ! alwaysOutput ) return ;
170173
You can’t perform that action at this time.
0 commit comments