File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
packages/@angular/cli/models/webpack-configs Expand file tree Collapse file tree 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) {
4444 const cssnanoPlugin = cssnano ( { safe : true , autoprefixer : false } ) ;
4545
4646 // 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 || '' ;
4949 const postcssUrlOptions = {
5050 url : ( URL : string ) => {
5151 // Only convert root relative URLs, which CSS-Loader won't process into require().
5252 if ( ! URL . startsWith ( '/' ) || URL . startsWith ( '//' ) ) {
5353 return URL ;
5454 }
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+ }
5864 }
5965 } ;
6066 const urlPlugin = postcssUrl ( postcssUrlOptions ) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,14 @@ export default function () {
4747 . then ( ( ) => expectToFail ( ( ) => expectFileToExist ( 'dist/component-img-absolute.svg' ) ) )
4848 . 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 / ) )
4949 . 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 - r e l a t i v 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 - r e l a t i v e \. s v g \) / ) )
57+ // Check with base-href and deploy-url flags.
5158 . then ( ( ) => ng ( 'build' , '--base-href=/base/' , '--deploy-url=deploy/' ,
5259 '--extract-css' , '--aot' ) )
5360 . then ( ( ) => expectFileToMatch ( 'dist/styles.bundle.css' ,
You can’t perform that action at this time.
0 commit comments