Skip to content

Commit 31276bc

Browse files
committed
fix(@angular/cli): take publicPath into account when building entry map
Fixes #7628
1 parent 5c7b7c5 commit 31276bc

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Add assets from `ConcatPlugin` to index.html.
2+
import * as path from 'path';
23

34
export class InsertConcatAssetsWebpackPlugin {
45
// Priority list of where to insert asset.
@@ -23,7 +24,7 @@ export class InsertConcatAssetsWebpackPlugin {
2324
throw new Error(`Cannot find file for ${entryName} script.`);
2425
}
2526

26-
return fileName;
27+
return path.join(htmlPluginData.assets.publicPath, fileName);
2728
});
2829

2930
let insertAt = 0;

tests/e2e/tests/misc/deploy-url.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { killAllProcesses } from '../../utils/process';
22
import { request } from '../../utils/http';
3-
import { ngServe } from '../../utils/project';
3+
import { ngServe, updateJsonFile } from '../../utils/project';
44
import { getGlobalVariable } from '../../utils/env';
5+
import { writeMultipleFiles } from '../../utils/fs';
56

67
export default function () {
78
// Skip this in Appveyor tests.
@@ -10,18 +11,29 @@ export default function () {
1011
}
1112

1213
return Promise.resolve()
14+
.then(() => writeMultipleFiles({
15+
'src/string-script.js': 'console.log(\'string-script\'); var number = 1+1;',
16+
})
17+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
18+
configJson['apps']['scripts'] = [
19+
'string-script.js',
20+
];
21+
}))
1322
// check when setup through command line arguments
1423
.then(() => ngServe('--deploy-url', '/deployurl/', '--base-href', '/deployurl/'))
1524
.then(() => request('http://localhost:4200'))
1625
.then(body => {
1726
if (!body.match(/<app-root><\/app-root>/)) {
18-
throw new Error('Response does not match expected value.');
27+
throw new Error('Response does not match expected value. (1)');
28+
}
29+
if (!body.match(/"\/deployurl\/scripts.bundle.js"/)) {
30+
throw new Error('Response does not match expected value. (2)');
1931
}
2032
})
2133
.then(() => request('http://localhost:4200/deployurl/'))
2234
.then(body => {
2335
if (!body.match(/<app-root><\/app-root>/)) {
24-
throw new Error('Response does not match expected value.');
36+
throw new Error('Response does not match expected value. (3)');
2537
}
2638
})
2739
.then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });

0 commit comments

Comments
 (0)