Skip to content

Commit ae8ea97

Browse files
committed
cleanup
1 parent a4ac1ef commit ae8ea97

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

addon/ng2/models/webpack-build-common.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ import * as CopyWebpackPlugin from 'copy-webpack-plugin';
33
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
44
import * as webpack from 'webpack';
55
import * as atl from 'awesome-typescript-loader';
6-
import { CliConfig } from './config';
76

87
import {findLazyModules} from './find-lazy-modules';
98

10-
export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
11-
const sourceRoot = path.resolve(projectRoot, `./${sourceDir}`);
129

13-
let outputPath: string = path.resolve(projectRoot, outputDir);
10+
export function getWebpackCommonConfig(projectRoot: string, sourceDir: string, outputDir: string) {
11+
const sourceRoot = path.resolve(projectRoot, sourceDir);
12+
const outputPath = path.resolve(projectRoot, outputDir);
1413
const lazyModules = findLazyModules(path.resolve(projectRoot, sourceDir));
1514

1615
return {
1716
devtool: 'source-map',
1817
resolve: {
1918
extensions: ['', '.ts', '.js'],
20-
root: path.resolve(projectRoot, `./${sourceDir}`)
19+
root: sourceRoot
2120
},
2221
context: path.resolve(__dirname, './'),
2322
entry: {
@@ -29,6 +28,15 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
2928
filename: '[name].bundle.js'
3029
},
3130
module: {
31+
preLoaders: [
32+
{
33+
test: /\.js$/,
34+
loader: 'source-map-loader',
35+
exclude: [
36+
/node_modules/
37+
]
38+
}
39+
],
3240
loaders: [
3341
{
3442
test: /\.ts$/,
@@ -37,7 +45,7 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
3745
loader: 'awesome-typescript-loader',
3846
query: {
3947
useForkChecker: true,
40-
tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`)
48+
tsconfig: path.resolve(sourceRoot, 'tsconfig.json')
4149
}
4250
}, {
4351
loader: 'angular2-template-loader'
@@ -58,7 +66,7 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
5866
new webpack.ContextReplacementPlugin(/.*/, sourceRoot, lazyModules),
5967
new atl.ForkCheckerPlugin(),
6068
new HtmlWebpackPlugin({
61-
template: path.resolve(projectRoot, `./${sourceDir}/index.html`),
69+
template: path.resolve(sourceRoot, 'index.html'),
6270
chunksSortMode: 'dependency'
6371
}),
6472
new webpack.optimize.CommonsChunkPlugin({

0 commit comments

Comments
 (0)