diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index 1f5ea0d0d526..d673bf64322a 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -12,7 +12,8 @@ export interface CliConfig { apps?: { root?: string; outDir?: string; - assets?: string; + publicPath?: string; + assets?: string[]; index?: string; main?: string; test?: string; diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 37668441c0b0..0226743e7f3f 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -31,6 +31,9 @@ "type": "string", "default": "dist/" }, + "publicPath": { + "type": "string" + }, "assets": { "fixme": true, "type": "array", diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 5642e7ced8b7..fb1ba9a5ccc1 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -42,6 +42,7 @@ export function getWebpackCommonConfig( entry: entry, output: { path: path.resolve(projectRoot, appConfig.outDir), + publicPath: appConfig.publicPath, filename: '[name].bundle.js', sourceMapFilename: '[name].bundle.map', chunkFilename: '[id].chunk.js' diff --git a/tests/e2e/tests/third-party/bootstrap_publicPath.ts b/tests/e2e/tests/third-party/bootstrap_publicPath.ts new file mode 100644 index 000000000000..50765e3cdedc --- /dev/null +++ b/tests/e2e/tests/third-party/bootstrap_publicPath.ts @@ -0,0 +1,31 @@ +import {npm, ng} from '../../utils/process'; +import {updateJsonFile} from '../../utils/project'; +import {expectFileToMatch} from '../../utils/fs'; +import {oneLineTrim} from 'common-tags'; + + +export default function() { + return Promise.resolve() + .then(() => npm('install', 'bootstrap@next')) + .then(() => updateJsonFile('angular-cli.json', configJson => { + const app = configJson['apps'][0]; + app['styles'].push('../node_modules/bootstrap/dist/css/bootstrap.css'); + app['scripts'].push( + '../node_modules/jquery/dist/jquery.js', + '../node_modules/tether/dist/js/tether.js', + '../node_modules/bootstrap/dist/js/bootstrap.js' + ); + app['publicPath'] = '/publicPathValue/'; + })) + .then(() => ng('build')) + .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*!\\n * jQuery JavaScript')) + .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*! tether ')) + .then(() => expectFileToMatch('dist/scripts.bundle.js', '/*!\\n * Bootstrap')) + .then(() => expectFileToMatch('dist/styles.bundle.js', '/*!\\n * Bootstrap')) + .then(() => expectFileToMatch('dist/index.html', oneLineTrim` + + + + + `)); +}