diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index 27b85cfad977..2fdb0a9fe381 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -58,9 +58,12 @@ export function getWebpackCommonConfig( devtool: sourcemap ? 'source-map' : false, resolve: { extensions: ['.ts', '.js'], - modules: [nodeModules] + modules: [nodeModules], }, - context: path.resolve(__dirname, './'), + resolveLoader: { + modules: [path.resolve(projectRoot, 'node_modules')] + }, + context: projectRoot, entry: entry, output: { path: path.resolve(projectRoot, appConfig.outDir), diff --git a/packages/angular-cli/models/webpack-build-test.js b/packages/angular-cli/models/webpack-build-test.js index 5c1541044e69..a82057506a8c 100644 --- a/packages/angular-cli/models/webpack-build-test.js +++ b/packages/angular-cli/models/webpack-build-test.js @@ -56,7 +56,7 @@ const getWebpackTestConfig = function (projectRoot, environment, appConfig, test return { devtool: testConfig.sourcemap ? 'inline-source-map' : 'eval', - context: path.resolve(__dirname, './'), + context: projectRoot, resolve: { extensions: ['.ts', '.js'], plugins: [