Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e5c63cb

Browse files
committedFeb 22, 2017
feat(@angular/cli): use same webpack config for karma
1 parent bc341e3 commit e5c63cb

File tree

18 files changed

+237
-221
lines changed

18 files changed

+237
-221
lines changed
 

‎packages/@angular/cli/blueprints/ng2/files/karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ module.exports = function (config) {
2929
fixWebpackSourcePaths: true
3030
},
3131
angularCli: {
32-
config: './.angular-cli.json',
3332
environment: 'dev'
3433
},
3534
reporters: config.angularCli && config.angularCli.codeCoverage

‎packages/@angular/cli/models/webpack-config.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const webpackMerge = require('webpack-merge');
22
import { CliConfig } from './config';
33
import { BuildOptions } from './build-options';
44
import {
5+
getBrowserConfig,
56
getCommonConfig,
67
getDevConfig,
78
getProdConfig,
@@ -20,6 +21,7 @@ export interface WebpackConfigOptions {
2021

2122
export class NgCliWebpackConfig {
2223
public config: any;
24+
public wco: WebpackConfigOptions;
2325
constructor(buildOptions: BuildOptions) {
2426

2527
this.validateBuildOptions(buildOptions);
@@ -32,26 +34,29 @@ export class NgCliWebpackConfig {
3234
buildOptions = this.addTargetDefaults(buildOptions);
3335
buildOptions = this.mergeConfigs(buildOptions, appConfig);
3436

35-
const wco: WebpackConfigOptions = { projectRoot, buildOptions, appConfig };
37+
this.wco = { projectRoot, buildOptions, appConfig };
38+
}
3639

40+
public buildConfig() {
3741
let webpackConfigs = [
38-
getCommonConfig(wco),
39-
getStylesConfig(wco),
40-
this.getTargetConfig(wco)
42+
getCommonConfig(this.wco),
43+
getBrowserConfig(this.wco),
44+
getStylesConfig(this.wco),
45+
this.getTargetConfig(this.wco)
4146
];
4247

43-
if (appConfig.main || appConfig.polyfills) {
44-
const typescriptConfigPartial = buildOptions.aot
45-
? getAotConfig(wco)
46-
: getNonAotConfig(wco);
48+
if (this.wco.appConfig.main || this.wco.appConfig.polyfills) {
49+
const typescriptConfigPartial = this.wco.buildOptions.aot
50+
? getAotConfig(this.wco)
51+
: getNonAotConfig(this.wco);
4752
webpackConfigs.push(typescriptConfigPartial);
4853
}
4954

50-
// add style config
5155
this.config = webpackMerge(webpackConfigs);
56+
return this.config;
5257
}
5358

54-
getTargetConfig(webpackConfigOptions: WebpackConfigOptions): any {
59+
public getTargetConfig(webpackConfigOptions: WebpackConfigOptions): any {
5560
switch (webpackConfigOptions.buildOptions.target) {
5661
case 'development':
5762
return getDevConfig(webpackConfigOptions);
@@ -61,14 +66,15 @@ export class NgCliWebpackConfig {
6166
}
6267

6368
// Validate build options
64-
private validateBuildOptions(buildOptions: BuildOptions) {
69+
public validateBuildOptions(buildOptions: BuildOptions) {
70+
buildOptions.target = buildOptions.target || 'development';
6571
if (buildOptions.target !== 'development' && buildOptions.target !== 'production') {
6672
throw new Error("Invalid build target. Only 'development' and 'production' are available.");
6773
}
6874
}
6975

7076
// Fill in defaults for build targets
71-
private addTargetDefaults(buildOptions: BuildOptions) {
77+
public addTargetDefaults(buildOptions: BuildOptions) {
7278
const targetDefaults: any = {
7379
development: {
7480
environment: 'dev',
@@ -89,7 +95,7 @@ export class NgCliWebpackConfig {
8995
}
9096

9197
// Fill in defaults from .angular-cli.json
92-
private mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
98+
public mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
9399
const mergeableOptions = {
94100
outputPath: appConfig.outDir,
95101
deployUrl: appConfig.deployUrl
@@ -98,7 +104,7 @@ export class NgCliWebpackConfig {
98104
return Object.assign({}, mergeableOptions, buildOptions);
99105
}
100106

101-
private addAppConfigDefaults(appConfig: any) {
107+
public addAppConfigDefaults(appConfig: any) {
102108
const appConfigDefaults: any = {
103109
scripts: [],
104110
styles: []
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as webpack from 'webpack';
2+
import * as path from 'path';
3+
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
5+
import { packageChunkSort } from '../../utilities/package-chunk-sort';
6+
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
7+
import { extraEntryParser, lazyChunksFilter } from './utils';
8+
import { WebpackConfigOptions } from '../webpack-config';
9+
10+
11+
export function getBrowserConfig(wco: WebpackConfigOptions) {
12+
const { projectRoot, buildOptions, appConfig } = wco;
13+
14+
const appRoot = path.resolve(projectRoot, appConfig.root);
15+
const nodeModules = path.resolve(projectRoot, 'node_modules');
16+
17+
let extraPlugins: any[] = [];
18+
19+
// figure out which are the lazy loaded entry points
20+
const lazyChunks = lazyChunksFilter([
21+
...extraEntryParser(appConfig.scripts, appRoot, 'scripts'),
22+
...extraEntryParser(appConfig.styles, appRoot, 'styles')
23+
]);
24+
25+
if (buildOptions.vendorChunk) {
26+
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
27+
name: 'vendor',
28+
chunks: ['main'],
29+
minChunks: (module: any) => module.resource && module.resource.startsWith(nodeModules)
30+
}));
31+
}
32+
33+
return {
34+
plugins: [
35+
new HtmlWebpackPlugin({
36+
template: path.resolve(appRoot, appConfig.index),
37+
filename: path.resolve(buildOptions.outputPath, appConfig.index),
38+
chunksSortMode: packageChunkSort(appConfig),
39+
excludeChunks: lazyChunks,
40+
xhtml: true
41+
}),
42+
new BaseHrefWebpackPlugin({
43+
baseHref: buildOptions.baseHref
44+
}),
45+
new webpack.optimize.CommonsChunkPlugin({
46+
minChunks: Infinity,
47+
name: 'inline'
48+
})
49+
].concat(extraPlugins)
50+
};
51+
}

‎packages/@angular/cli/models/webpack-configs/common.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
33
import { GlobCopyWebpackPlugin } from '../../plugins/glob-copy-webpack-plugin';
4-
import { packageChunkSort } from '../../utilities/package-chunk-sort';
5-
import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
6-
import { extraEntryParser, lazyChunksFilter, getOutputHashFormat } from './utils';
4+
import { extraEntryParser, getOutputHashFormat } from './utils';
75
import { WebpackConfigOptions } from '../webpack-config';
86

97
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
10-
const HtmlWebpackPlugin = require('html-webpack-plugin');
118

129

1310
/**
@@ -32,12 +29,6 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
3229
let extraRules: any[] = [];
3330
let entryPoints: { [key: string]: string[] } = {};
3431

35-
// figure out which are the lazy loaded entry points
36-
const lazyChunks = lazyChunksFilter([
37-
...extraEntryParser(appConfig.scripts, appRoot, 'scripts'),
38-
...extraEntryParser(appConfig.styles, appRoot, 'styles')
39-
]);
40-
4132
if (appConfig.main) {
4233
entryPoints['main'] = [path.resolve(appRoot, appConfig.main)];
4334
}
@@ -56,19 +47,10 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
5647
// add entry points and lazy chunks
5748
globalScripts.forEach(script => {
5849
let scriptPath = `script-loader!${script.path}`;
59-
if (script.lazy) { lazyChunks.push(script.entry); }
6050
entryPoints[script.entry] = (entryPoints[script.entry] || []).concat(scriptPath);
6151
});
6252
}
6353

64-
if (buildOptions.vendorChunk) {
65-
extraPlugins.push(new webpack.optimize.CommonsChunkPlugin({
66-
name: 'vendor',
67-
chunks: ['main'],
68-
minChunks: (module: any) => module.resource && module.resource.startsWith(nodeModules)
69-
}));
70-
}
71-
7254
// process asset entries
7355
if (appConfig.assets) {
7456
extraPlugins.push(new GlobCopyWebpackPlugin({
@@ -111,21 +93,7 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
11193
].concat(extraRules)
11294
},
11395
plugins: [
114-
new webpack.NoEmitOnErrorsPlugin(),
115-
new HtmlWebpackPlugin({
116-
template: path.resolve(appRoot, appConfig.index),
117-
filename: path.resolve(buildOptions.outputPath, appConfig.index),
118-
chunksSortMode: packageChunkSort(appConfig),
119-
excludeChunks: lazyChunks,
120-
xhtml: true
121-
}),
122-
new BaseHrefWebpackPlugin({
123-
baseHref: buildOptions.baseHref
124-
}),
125-
new webpack.optimize.CommonsChunkPlugin({
126-
minChunks: Infinity,
127-
name: 'inline'
128-
})
96+
new webpack.NoEmitOnErrorsPlugin()
12997
].concat(extraPlugins),
13098
node: {
13199
fs: 'empty',
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
export * from './browser';
12
export * from './common';
23
export * from './development';
34
export * from './production';
45
export * from './styles';
6+
export * from './test';
57
export * from './typescript';
68
export * from './utils';
79
export * from './xi18n';

‎packages/@angular/cli/models/webpack-configs/test.js

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import * as path from 'path';
2+
import * as webpack from 'webpack';
3+
4+
import { CliConfig } from '../config';
5+
import { WebpackTestOptions } from '../webpack-test-config';
6+
7+
/**
8+
* Enumerate loaders and their dependencies from this file to let the dependency validator
9+
* know they are used.
10+
*
11+
* require('istanbul-instrumenter-loader')
12+
*
13+
*/
14+
15+
16+
export function getTestConfig(testConfig: WebpackTestOptions) {
17+
18+
const configPath = CliConfig.configFilePath();
19+
const projectRoot = path.dirname(configPath);
20+
const appConfig = CliConfig.fromProject().config.apps[0];
21+
const extraRules: any[] = [];
22+
23+
if (testConfig.codeCoverage) {
24+
extraRules.push({
25+
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
26+
enforce: 'post',
27+
exclude: [
28+
/\.(e2e|spec)\.ts$/,
29+
/node_modules/
30+
]
31+
});
32+
}
33+
34+
return {
35+
devtool: testConfig.sourcemap ? 'inline-source-map' : 'eval',
36+
entry: {
37+
test: path.resolve(projectRoot, appConfig.root, appConfig.test)
38+
},
39+
module: {
40+
rules: [].concat(extraRules)
41+
},
42+
plugins: [
43+
new webpack.SourceMapDevToolPlugin({
44+
filename: null, // if no value is provided the sourcemap is inlined
45+
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
46+
})
47+
]
48+
};
49+
}

‎packages/@angular/cli/models/webpack-configs/typescript.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,27 @@ export const getAotConfig = function(wco: WebpackConfigOptions) {
116116
]
117117
};
118118
};
119+
120+
export const getNonAotTestConfig = function(wco: WebpackConfigOptions) {
121+
return {
122+
module: {
123+
rules: [
124+
{
125+
test: /\.ts$/,
126+
loader: webpackLoader,
127+
query: { module: 'commonjs' },
128+
exclude: [/\.(e2e)\.ts$/]
129+
}
130+
]
131+
},
132+
plugins: [
133+
_createAotPlugin(wco, {
134+
exclude: [],
135+
skipCodeGeneration: true,
136+
compilerOptions: {
137+
module: 'commonjs'
138+
}
139+
}),
140+
]
141+
};
142+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as webpack from 'webpack';
2+
const webpackMerge = require('webpack-merge');
3+
4+
import { BuildOptions } from './build-options';
5+
import { NgCliWebpackConfig } from './webpack-config';
6+
import {
7+
getCommonConfig,
8+
getStylesConfig,
9+
getNonAotTestConfig,
10+
getTestConfig
11+
} from './webpack-configs';
12+
13+
export interface WebpackTestOptions extends BuildOptions {
14+
codeCoverage?: boolean;
15+
}
16+
export class WebpackTestConfig extends NgCliWebpackConfig {
17+
constructor(private testOptions: WebpackTestOptions) {
18+
super(testOptions);
19+
}
20+
21+
public buildConfig() {
22+
let webpackConfigs = [
23+
getCommonConfig(this.wco),
24+
getStylesConfig(this.wco),
25+
this.getTargetConfig(this.wco),
26+
getNonAotTestConfig(this.wco),
27+
getTestConfig(this.testOptions)
28+
];
29+
30+
this.config = webpackMerge(webpackConfigs);
31+
32+
// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
33+
this.config.plugins = this.config.plugins.filter((plugin: any) =>
34+
!(plugin instanceof webpack.optimize.CommonsChunkPlugin));
35+
36+
return this.config;
37+
}
38+
}

‎packages/@angular/cli/models/webpack-xi18n-config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ export class XI18nWebpackConfig extends NgCliWebpackConfig {
1616

1717
public config: any;
1818

19-
constructor(extractOptions: XI18WebpackOptions) {
20-
19+
constructor(public extractOptions: XI18WebpackOptions) {
2120
super({
2221
target: 'development',
2322
verbose: extractOptions.verbose,
2423
progress: extractOptions.progress
2524
});
25+
super.buildConfig();
26+
}
2627

28+
public buildConfig() {
2729
const configPath = CliConfig.configFilePath();
2830
const projectRoot = path.dirname(configPath);
2931
const appConfig = CliConfig.fromProject().config.apps[0];
3032

3133
const extractI18nConfig =
3234
getWebpackExtractI18nConfig(projectRoot,
3335
appConfig,
34-
extractOptions.genDir,
35-
extractOptions.i18nFormat);
36+
this.extractOptions.genDir,
37+
this.extractOptions.i18nFormat);
3638

3739
this.config = webpackMerge([this.config, extractI18nConfig]);
40+
return this.config;
3841
}
3942
}

‎packages/@angular/cli/plugins/karma.js renamed to ‎packages/@angular/cli/plugins/karma.ts

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
const path = require('path');
2-
const fs = require('fs');
1+
import * as path from 'path';
2+
import * as fs from 'fs';
33

4-
const getTestConfig = require('../models/webpack-configs/test').getTestConfig;
4+
import { CliConfig } from '../models/config';
5+
import { Pattern } from './glob-copy-webpack-plugin';
6+
import { extraEntryParser } from '../models/webpack-configs/utils';
7+
import { WebpackTestConfig, WebpackTestOptions } from '../models/webpack-test-config';
58

6-
function isDirectory(path) {
9+
10+
function isDirectory(path: string) {
711
try {
812
return fs.statSync(path).isDirectory();
913
} catch (_) {
1014
return false;
1115
}
1216
}
1317

14-
const init = (config) => {
15-
// load Angular CLI config
16-
if (!config.angularCli || !config.angularCli.config) {
17-
throw new Error('Missing \'angularCli.config\' entry in Karma config');
18-
}
19-
const angularCliConfig = require(path.join(config.basePath, config.angularCli.config));
20-
const appConfig = angularCliConfig.apps[0];
18+
const init: any = (config: any) => {
19+
const appConfig = CliConfig.fromProject().config.apps[0];
2120
const appRoot = path.join(config.basePath, appConfig.root);
22-
const environment = config.angularCli.environment || 'dev';
23-
const testConfig = {
24-
codeCoverage: config.angularCli.codeCoverage || false,
25-
sourcemap: config.angularCli.sourcemap,
26-
progress: config.angularCli.progress
27-
}
21+
const testConfig: WebpackTestOptions = Object.assign({
22+
environment: 'dev',
23+
codeCoverage: false,
24+
sourcemap: true,
25+
progress: true,
26+
}, config.angularCli);
2827

2928
// Add assets. This logic is mimics the one present in GlobCopyWebpackPlugin.
3029
if (appConfig.assets) {
3130
config.proxies = config.proxies || {};
32-
appConfig.assets.forEach(pattern => {
31+
appConfig.assets.forEach((pattern: Pattern) => {
3332
// Convert all string patterns to Pattern type.
3433
pattern = typeof pattern === 'string' ? { glob: pattern } : pattern;
3534
// Add defaults.
@@ -50,7 +49,7 @@ const init = (config) => {
5049

5150
// The `files` entry serves the file from `/base/{asset.input}/{asset.glob}`.
5251
// We need to add a URL rewrite that exposes the asset as `/{asset.output}/{asset.glob}`.
53-
let relativePath, proxyPath;
52+
let relativePath: string, proxyPath: string;
5453
if (fs.existsSync(assetPath)) {
5554
relativePath = path.relative(config.basePath, assetPath);
5655
proxyPath = path.join(pattern.output, pattern.glob);
@@ -66,8 +65,8 @@ const init = (config) => {
6665
});
6766
}
6867

69-
// add webpack config
70-
const webpackConfig = getTestConfig(config.basePath, environment, appConfig, testConfig);
68+
// Add webpack config.
69+
const webpackConfig = new WebpackTestConfig(testConfig).buildConfig();
7170
const webpackMiddlewareConfig = {
7271
noInfo: true, // Hide webpack output because its noisy.
7372
stats: { // Also prevent chunk and module display output, cleaner look. Only emit errors.
@@ -80,23 +79,22 @@ const init = (config) => {
8079
chunkModules: false
8180
},
8281
watchOptions: {
83-
poll: config.angularCli.poll
82+
poll: testConfig.poll
8483
}
8584
};
8685

8786
config.webpack = Object.assign(webpackConfig, config.webpack);
8887
config.webpackMiddleware = Object.assign(webpackMiddlewareConfig, config.webpackMiddleware);
8988

90-
// replace the @angular/cli preprocessor with webpack+sourcemap
89+
// Replace the @angular/cli preprocessor with webpack+sourcemap.
9190
Object.keys(config.preprocessors)
9291
.filter((file) => config.preprocessors[file].indexOf('@angular/cli') !== -1)
9392
.map((file) => config.preprocessors[file])
9493
.map((arr) => arr.splice(arr.indexOf('@angular/cli'), 1, 'webpack', 'sourcemap'));
9594

96-
// Add global scripts
95+
// Add global scripts. This logic mimics the one in webpack-configs/common.
9796
if (appConfig.scripts && appConfig.scripts.length > 0) {
98-
const globalScriptPatterns = appConfig.scripts
99-
.map(script => typeof script === 'string' ? { input: script } : script)
97+
const globalScriptPatterns = extraEntryParser(appConfig.scripts, appRoot, 'scripts')
10098
// Neither renamed nor lazy scripts are currently supported
10199
.filter(script => !(script.output || script.lazy))
102100
.map(script => ({
@@ -109,7 +107,7 @@ const init = (config) => {
109107
// Unshift elements onto the beginning of the files array.
110108
// It's important to not replace the array, because
111109
// karma already has a reference to the existing array.
112-
Array.prototype.unshift.apply(config.files, globalScriptPatterns);
110+
config.files.unshift(...globalScriptPatterns);
113111
}
114112

115113
// Add polyfills file before everything else
@@ -120,19 +118,20 @@ const init = (config) => {
120118
included: true,
121119
served: true,
122120
watched: true
123-
}
124-
Array.prototype.unshift.apply(config.files, [polyfillsPattern]);
121+
};
125122
config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap'];
123+
// Same as above.
124+
config.files.unshift(polyfillsPattern);
126125
}
127-
}
126+
};
128127

129128
init.$inject = ['config'];
130129

131-
// dummy preprocessor, just to keep karma from showing a warning
132-
const preprocessor = () => (content, file, done) => done(null, content);
130+
// Dummy preprocessor, just to keep karma from showing a warning.
131+
const preprocessor: any = () => (content: any, _file: string, done: any) => done(null, content);
133132
preprocessor.$inject = [];
134133

135-
// also export karma-webpack and karma-sourcemap-loader
134+
// Also export karma-webpack and karma-sourcemap-loader.
136135
module.exports = Object.assign({
137136
'framework:@angular/cli': ['factory', init],
138137
'preprocessor:@angular/cli': ['factory', preprocessor]

‎packages/@angular/cli/tasks/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default Task.extend({
2525
}
2626
rimraf.sync(path.resolve(project.root, outputPath));
2727

28-
const webpackConfig = new NgCliWebpackConfig(runTaskOptions).config;
28+
const webpackConfig = new NgCliWebpackConfig(runTaskOptions).buildConfig();
2929
const webpackCompiler = webpack(webpackConfig);
3030
const statsConfig = getWebpackStatsConfig(runTaskOptions.verbose);
3131

‎packages/@angular/cli/tasks/eject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ export default Task.extend({
403403
throw new SilentError ('Output path MUST not be project root directory!');
404404
}
405405

406-
const webpackConfig = new NgCliWebpackConfig(runTaskOptions).config;
406+
const webpackConfig = new NgCliWebpackConfig(runTaskOptions).buildConfig();
407407
const serializer = new JsonWebpackSerializer(process.cwd(), outputPath);
408408
const output = serializer.serialize(webpackConfig);
409409
const webpackConfigStr = `${serializer.generateVariables()}\n\nmodule.exports = ${output};\n`;

‎packages/@angular/cli/tasks/extract-i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const Extracti18nTask = Task.extend({
2424
i18nFormat: runTaskOptions.i18nFormat,
2525
verbose: runTaskOptions.verbose,
2626
progress: runTaskOptions.progress
27-
}).config;
27+
}).buildConfig();
2828

2929
const webpackCompiler = webpack(config);
3030

‎packages/@angular/cli/tasks/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default Task.extend({
3939

4040
serveTaskOptions = Object.assign({}, serveDefaults, serveTaskOptions);
4141

42-
let webpackConfig = new NgCliWebpackConfig(serveTaskOptions).config;
42+
let webpackConfig = new NgCliWebpackConfig(serveTaskOptions).buildConfig();
4343

4444
const serverAddress = url.format({
4545
protocol: serveTaskOptions.ssl ? 'https' : 'http',

‎plugins/karma.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This file is necessary when using a linked @angular/cli to this repo, meaning that
22
// require('@angular/cli/plugins/karma') will load this file, and we just forward to
33
// the actual published file.
4+
require('../lib/bootstrap-local');
45
module.exports = require('../packages/@angular/cli/plugins/karma');

‎plugins/webpack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is necessary when using a linked angular-cli to this repo, meaning that
1+
// This file is necessary when using a linked @angular/cli to this repo, meaning that
22
// require('@angular/cli/plugins/webpack') will load this file, and we just forward to
33
// the actual published file.
44
require('../lib/bootstrap-local');

‎tests/e2e/tests/build/styles/imports.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import {
22
writeMultipleFiles,
3-
deleteFile,
43
expectFileToMatch,
54
replaceInFile
65
} from '../../../utils/fs';
76
import { expectToFail } from '../../../utils/utils';
87
import { ng } from '../../../utils/process';
98
import { stripIndents } from 'common-tags';
109
import { updateJsonFile } from '../../../utils/project';
10+
import { getGlobalVariable } from '../../../utils/env';
1111

1212
export default function () {
13+
// Disable parts of it in webpack tests.
14+
const ejected = getGlobalVariable('argv').eject;
15+
1316
const extensions = ['css', 'scss', 'less', 'styl'];
1417
let promise = Promise.resolve();
1518

@@ -56,6 +59,8 @@ export default function () {
5659
/.outer.*.inner.*background:\s*#[fF]+/))
5760
.then(() => expectFileToMatch('dist/main.bundle.js',
5861
/h1.*background:\s*#000+/))
62+
// Also check imports work on ng test
63+
.then(() => !ejected && ng('test', '--single-run'))
5964
// change files back
6065
.then(() => updateJsonFile('.angular-cli.json', configJson => {
6166
const app = configJson['apps'][0];

0 commit comments

Comments
 (0)
Please sign in to comment.