diff --git a/package.json b/package.json index a25c71729a40..a3cffd0ea50f 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "homepage": "https://github.com/angular/angular-cli", "dependencies": { "@angular-cli/ast-tools": "^1.0.0", + "@angular-cli/base-href-webpack": "^1.0.6", "@angular/common": "~2.1.0", "@angular/compiler": "~2.1.0", "@angular/compiler-cli": "~2.1.0", @@ -52,6 +53,7 @@ "@angular/platform-browser": "~2.1.0", "@angular/platform-server": "~2.1.0", "@angular/tsc-wrapped": "^0.3.0", + "@ngtools/webpack": "^1.1.4", "angular2-template-loader": "^0.5.0", "awesome-typescript-loader": "^2.2.3", "chalk": "^1.1.3", diff --git a/packages/angular-cli/lib/config/schema.d.ts b/packages/angular-cli/lib/config/schema.d.ts index c1fd6850d710..1c05de89e75e 100644 --- a/packages/angular-cli/lib/config/schema.d.ts +++ b/packages/angular-cli/lib/config/schema.d.ts @@ -27,6 +27,11 @@ export interface CliConfig { * Global scripts to be included in the build. */ scripts?: string[]; + /** + * Global scripts to be used internally. + * See https://webpack.github.io/docs/library-and-externals.html + */ + externals: {[name: string]: string}; /** * Name and corresponding file for environment config. */ diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index b02dbb6c1026..75c2a1ea899b 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -74,6 +74,11 @@ }, "additionalProperties": false }, + "externals": { + "description": "Global scripts to be used internally.", + "type": "object", + "additionalProperties": true + }, "environments": { "description": "Name and corresponding file for environment config.", "type": "object", diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index c2c90f91f1e5..71abf3bdcfc0 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -22,6 +22,7 @@ export function getWebpackCommonConfig( const scripts = appConfig.scripts ? appConfig.scripts.map((script: string) => path.resolve(appRoot, script)) : []; + const externals = appConfig.externals || {}; let entry: { [key: string]: string[] } = { main: [appMain] @@ -43,6 +44,7 @@ export function getWebpackCommonConfig( path: path.resolve(projectRoot, appConfig.outDir), filename: '[name].bundle.js' }, + externals: externals, module: { rules: [ {