@@ -3,21 +3,20 @@ import * as CopyWebpackPlugin from 'copy-webpack-plugin';
3
3
import * as HtmlWebpackPlugin from 'html-webpack-plugin' ;
4
4
import * as webpack from 'webpack' ;
5
5
import * as atl from 'awesome-typescript-loader' ;
6
- import { CliConfig } from './config' ;
7
6
8
7
import { findLazyModules } from './find-lazy-modules' ;
9
8
10
- export function getWebpackCommonConfig ( projectRoot : string , sourceDir : string ) {
11
- const sourceRoot = path . resolve ( projectRoot , `./${ sourceDir } ` ) ;
12
9
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 ) ;
14
13
const lazyModules = findLazyModules ( path . resolve ( projectRoot , sourceDir ) ) ;
15
14
16
15
return {
17
16
devtool : 'source-map' ,
18
17
resolve : {
19
18
extensions : [ '' , '.ts' , '.js' ] ,
20
- root : path . resolve ( projectRoot , `./ ${ sourceDir } ` )
19
+ root : sourceRoot
21
20
} ,
22
21
context : path . resolve ( __dirname , './' ) ,
23
22
entry : {
@@ -29,6 +28,15 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
29
28
filename : '[name].bundle.js'
30
29
} ,
31
30
module : {
31
+ preLoaders : [
32
+ {
33
+ test : / \. j s $ / ,
34
+ loader : 'source-map-loader' ,
35
+ exclude : [
36
+ / n o d e _ m o d u l e s /
37
+ ]
38
+ }
39
+ ] ,
32
40
loaders : [
33
41
{
34
42
test : / \. t s $ / ,
@@ -37,7 +45,7 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
37
45
loader : 'awesome-typescript-loader' ,
38
46
query : {
39
47
useForkChecker : true ,
40
- tsconfig : path . resolve ( projectRoot , `./ ${ sourceDir } / tsconfig.json` )
48
+ tsconfig : path . resolve ( sourceRoot , ' tsconfig.json' )
41
49
}
42
50
} , {
43
51
loader : 'angular2-template-loader'
@@ -58,7 +66,7 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
58
66
new webpack . ContextReplacementPlugin ( / .* / , sourceRoot , lazyModules ) ,
59
67
new atl . ForkCheckerPlugin ( ) ,
60
68
new HtmlWebpackPlugin ( {
61
- template : path . resolve ( projectRoot , `./ ${ sourceDir } / index.html` ) ,
69
+ template : path . resolve ( sourceRoot , ' index.html' ) ,
62
70
chunksSortMode : 'dependency'
63
71
} ) ,
64
72
new webpack . optimize . CommonsChunkPlugin ( {
0 commit comments