File tree 2 files changed +19
-6
lines changed
packages/@angular/cli/models/webpack-configs
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -44,17 +44,23 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
44
44
const cssnanoPlugin = cssnano ( { safe : true , autoprefixer : false } ) ;
45
45
46
46
// Convert absolute resource URLs to account for base-href and deploy-url.
47
- const baseHref = wco . buildOptions . baseHref ;
48
- const deployUrl = wco . buildOptions . deployUrl ;
47
+ const baseHref = wco . buildOptions . baseHref || '' ;
48
+ const deployUrl = wco . buildOptions . deployUrl || '' ;
49
49
const postcssUrlOptions = {
50
50
url : ( URL : string ) => {
51
51
// Only convert root relative URLs, which CSS-Loader won't process into require().
52
52
if ( ! URL . startsWith ( '/' ) || URL . startsWith ( '//' ) ) {
53
53
return URL ;
54
54
}
55
- // Join together base-href, deploy-url and the original URL.
56
- // Also dedupe multiple slashes into single ones.
57
- return `/${ baseHref || '' } /${ deployUrl || '' } /${ URL } ` . replace ( / \/ \/ + / g, '/' ) ;
55
+
56
+ if ( deployUrl . match ( / : \/ \/ / ) ) {
57
+ // If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
58
+ return `${ deployUrl . replace ( / \/ $ / , '' ) } ${ URL } ` ;
59
+ } else {
60
+ // Join together base-href, deploy-url and the original URL.
61
+ // Also dedupe multiple slashes into single ones.
62
+ return `/${ baseHref } /${ deployUrl } /${ URL } ` . replace ( / \/ \/ + / g, '/' ) ;
63
+ }
58
64
}
59
65
} ;
60
66
const urlPlugin = postcssUrl ( postcssUrlOptions ) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,14 @@ export default function () {
47
47
. then ( ( ) => expectToFail ( ( ) => expectFileToExist ( 'dist/component-img-absolute.svg' ) ) )
48
48
. then ( ( ) => expectFileMatchToExist ( './dist' , / g l o b a l - i m g - r e l a t i v e \. [ 0 - 9 a - f ] { 20 } \. s v g / ) )
49
49
. then ( ( ) => expectFileMatchToExist ( './dist' , / c o m p o n e n t - i m g - r e l a t i v e \. [ 0 - 9 a - f ] { 20 } \. s v g / ) )
50
- // Also check with base-href and deploy-url flags.
50
+ // Check urls with scheme are used as is.
51
+ . then ( ( ) => ng ( 'build' , '--base-href=/base/' , '--deploy-url=http://deploy.url/' ,
52
+ '--extract-css' ) )
53
+ . then ( ( ) => expectFileToMatch ( 'dist/styles.bundle.css' ,
54
+ / u r l \( h t t p : \/ \/ d e p l o y \. u r l \/ g l o b a l - i m g - a b s o l u t e \. s v g \) / ) )
55
+ . then ( ( ) => expectFileToMatch ( 'dist/main.bundle.js' ,
56
+ / u r l \( h t t p : \/ \/ d e p l o y \. u r l \/ c o m p o n e n t - i m g - a b s o l u t e \. s v g \) / ) )
57
+ // Check with base-href and deploy-url flags.
51
58
. then ( ( ) => ng ( 'build' , '--base-href=/base/' , '--deploy-url=deploy/' ,
52
59
'--extract-css' , '--aot' ) )
53
60
. then ( ( ) => expectFileToMatch ( 'dist/styles.bundle.css' ,
You can’t perform that action at this time.
0 commit comments