diff --git a/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts b/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts index 45ff96e63d84..039c0afafd00 100644 --- a/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts +++ b/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts @@ -1,5 +1,5 @@ // Add assets from `ConcatPlugin` to index.html. -import * as path from 'path'; + export class InsertConcatAssetsWebpackPlugin { // Priority list of where to insert asset. @@ -24,7 +24,13 @@ export class InsertConcatAssetsWebpackPlugin { throw new Error(`Cannot find file for ${entryName} script.`); } - return path.join(htmlPluginData.assets.publicPath, fileName); + if (htmlPluginData.assets.publicPath) { + if (htmlPluginData.assets.publicPath.endsWith('/')) { + return htmlPluginData.assets.publicPath + fileName; + } + return htmlPluginData.assets.publicPath + '/' + fileName; + } + return fileName; }); let insertAt = 0; diff --git a/tests/e2e/tests/build/deploy-url.ts b/tests/e2e/tests/build/deploy-url.ts index 83d66b5ba5a2..5882d2c8e5ba 100644 --- a/tests/e2e/tests/build/deploy-url.ts +++ b/tests/e2e/tests/build/deploy-url.ts @@ -24,6 +24,8 @@ export default function () { .then(() => expectFileToMatch('dist/index.html', 'deployUrl/main.bundle.js')) // verify --deploy-url isn't applied to extracted css urls .then(() => expectFileToMatch('dist/styles.bundle.css', /url\(more\.[0-9a-f]{20}\.svg\)/)) + .then(() => ng('build', '--deploy-url=http://example.com/some/path/', '--extract-css')) + .then(() => expectFileToMatch('dist/index.html', 'http://example.com/some/path/main.bundle.js')) // verify option also works in config .then(() => updateJsonFile('.angular-cli.json', configJson => { const app = configJson['apps'][0];