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 870d9c7081c4..45ff96e63d84 100644 --- a/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts +++ b/packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts @@ -1,4 +1,5 @@ // Add assets from `ConcatPlugin` to index.html. +import * as path from 'path'; export class InsertConcatAssetsWebpackPlugin { // Priority list of where to insert asset. @@ -23,7 +24,7 @@ export class InsertConcatAssetsWebpackPlugin { throw new Error(`Cannot find file for ${entryName} script.`); } - return fileName; + return path.join(htmlPluginData.assets.publicPath, fileName); }); let insertAt = 0; diff --git a/tests/e2e/tests/misc/deploy-url.ts b/tests/e2e/tests/misc/deploy-url.ts index ed3d28c48f45..ef2393f3b33f 100644 --- a/tests/e2e/tests/misc/deploy-url.ts +++ b/tests/e2e/tests/misc/deploy-url.ts @@ -1,7 +1,8 @@ import { killAllProcesses } from '../../utils/process'; import { request } from '../../utils/http'; -import { ngServe } from '../../utils/project'; +import { ngServe, updateJsonFile } from '../../utils/project'; import { getGlobalVariable } from '../../utils/env'; +import { writeMultipleFiles } from '../../utils/fs'; export default function () { // Skip this in Appveyor tests. @@ -10,18 +11,29 @@ export default function () { } return Promise.resolve() + .then(() => writeMultipleFiles({ + 'src/string-script.js': 'console.log(\'string-script\'); var number = 1+1;', + }) + .then(() => updateJsonFile('.angular-cli.json', configJson => { + configJson['apps'][0]['scripts'] = [ + 'string-script.js', + ]; + })) // check when setup through command line arguments .then(() => ngServe('--deploy-url', '/deployurl/', '--base-href', '/deployurl/')) .then(() => request('http://localhost:4200')) .then(body => { if (!body.match(/<\/app-root>/)) { - throw new Error('Response does not match expected value.'); + throw new Error('Response does not match expected value. (1)'); + } + if (!body.match(/"\/deployurl\/scripts.bundle.js"/)) { + throw new Error('Response does not match expected value. (2)'); } }) .then(() => request('http://localhost:4200/deployurl/')) .then(body => { if (!body.match(/<\/app-root>/)) { - throw new Error('Response does not match expected value.'); + throw new Error('Response does not match expected value. (3)'); } }) .then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });