File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ module.exports = function (source, map) {
9292 } ) ;
9393
9494 if ( '_emitThemePartial' in loader ) {
95- loader . _emitThemePartial ( result . css ) ;
95+ loader . _emitThemePartial ( loader . resourcePath , result . css ) ;
9696 } else {
9797 throw new Error ( 'Theme loader missing _emitThemePartial function. Did you forget to include the ThemePlugin?' ) ;
9898 }
Original file line number Diff line number Diff line change @@ -69,24 +69,28 @@ function ThemePlugin(options) {
6969
7070ThemePlugin . prototype . apply = function apply ( compiler ) {
7171 const themes = this . options . themes ;
72- const themePartials = [ ] ;
72+ const themePartials = { } ;
7373
7474 compiler . plugin ( 'compilation' , compilation => {
7575 compilation . plugin ( 'normal-module-loader' , ( context , module ) => {
76- context . _emitThemePartial = ( themeSource ) => {
77- themePartials . push ( themeSource ) ;
76+ context . _emitThemePartial = ( resourcePath , themeSource ) => {
77+ themePartials [ resourcePath ] = themeSource ;
7878 } ;
7979 } ) ;
8080 } ) ;
8181
8282 compiler . plugin ( 'emit' , ( compilation , done ) => {
83- if ( themePartials . length === 0 ) {
83+ const themePartialResources = Object . keys ( themePartials ) ;
84+
85+ if ( themePartialResources . length === 0 ) {
8486 done ( ) ;
8587 return ;
8688 }
8789
8890 // Concat theme partials
89- const source = themePartials . join ( '\n' ) ;
91+ const source = themePartialResources
92+ . map ( resourcePath => themePartials [ resourcePath ] )
93+ . join ( '\n' ) ;
9094
9195 generateThemes ( themes , source ) . then ( function ( results ) {
9296 const themeAssets = results . reduce ( ( acc , theme ) => {
You can’t perform that action at this time.
0 commit comments