File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
45
45
const cssnanoPlugin = cssnano ( { safe : true , autoprefixer : false } ) ;
46
46
47
47
// Convert absolute resource URLs to account for base-href and deploy-url.
48
+ const baseHref = wco . buildOptions . baseHref ;
49
+ const deployUrl = wco . buildOptions . deployUrl ;
48
50
const postcssUrlOptions = {
49
51
url : ( URL : string ) => {
50
52
// Only convert absolute URLs, which CSS-Loader won't process into require().
@@ -53,11 +55,14 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
53
55
}
54
56
// Join together base-href, deploy-url and the original URL.
55
57
// Also dedupe multiple slashes into single ones.
56
- return `/${ wco . buildOptions . baseHref || '' } /${ wco . buildOptions . deployUrl || '' } /${ URL } `
57
- . replace ( / \/ \/ + / g, '/' ) ;
58
+ return `/${ baseHref || '' } /${ deployUrl || '' } /${ URL } ` . replace ( / \/ \/ + / g, '/' ) ;
58
59
}
59
60
} ;
60
61
const urlPlugin = postcssUrl ( postcssUrlOptions ) ;
62
+ // We need to save baseHref and deployUrl for the Ejected webpack config to work (we reuse
63
+ // the function defined above).
64
+ ( postcssUrlOptions as any ) . baseHref = baseHref ;
65
+ ( postcssUrlOptions as any ) . deployUrl = deployUrl ;
61
66
// Save the original options as arguments for eject.
62
67
urlPlugin [ postcssArgs ] = postcssUrlOptions ;
63
68
Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ class JsonWebpackSerializer {
141
141
this . variableImports [ 'postcss-url' ] = 'postcssUrl' ;
142
142
let args = '' ;
143
143
if ( x [ postcssArgs ] && x [ postcssArgs ] . url ) {
144
+ this . variables [ 'baseHref' ] = JSON . stringify ( x [ postcssArgs ] . baseHref ) ;
145
+ this . variables [ 'deployUrl' ] = JSON . stringify ( x [ postcssArgs ] . deployUrl ) ;
144
146
args = `{"url": ${ x [ postcssArgs ] . url . toString ( ) } }` ;
145
147
}
146
148
return this . _escape ( `postcssUrl(${ args } )` ) ;
You can’t perform that action at this time.
0 commit comments