1
1
/*jslint node: true */
2
2
'use strict' ;
3
3
4
- function getWebpackConfig ( skyPagesConfig , argv ) {
5
-
6
- function spaPath ( ) {
7
- return skyPagesConfigUtil . spaPath . apply ( skyPagesConfigUtil , arguments ) ;
8
- }
9
-
10
- function outPath ( ) {
11
- return skyPagesConfigUtil . outPath . apply ( skyPagesConfigUtil , arguments ) ;
12
- }
13
-
14
- const path = require ( 'path' ) ;
4
+ const path = require ( 'path' ) ;
5
+ const DefinePlugin = require ( 'webpack/lib/DefinePlugin' ) ;
6
+ const LoaderOptionsPlugin = require ( 'webpack/lib/LoaderOptionsPlugin' ) ;
7
+ const ContextReplacementPlugin = require ( 'webpack/lib/ContextReplacementPlugin' ) ;
8
+ const ProcessExitCode = require ( '../../plugin/process-exit-code' ) ;
9
+ const SkyTsLintCheckerPlugin = require ( '../../loader/sky-tslint/checker-plugin' ) ;
10
+ const skyPagesConfigUtil = require ( '../sky-pages/sky-pages.config' ) ;
11
+ const aliasBuilder = require ( './alias-builder' ) ;
12
+
13
+ function spaPath ( ) {
14
+ return skyPagesConfigUtil . spaPath . apply ( skyPagesConfigUtil , arguments ) ;
15
+ }
15
16
16
- const DefinePlugin = require ( 'webpack/lib/DefinePlugin' ) ;
17
- const LoaderOptionsPlugin = require ( 'webpack/lib/LoaderOptionsPlugin' ) ;
18
- const ContextReplacementPlugin = require ( 'webpack/lib/ContextReplacementPlugin' ) ;
19
- const ProcessExitCode = require ( '../../plugin/process-exit-code' ) ;
20
- const skyPagesConfigUtil = require ( '../sky-pages/sky-pages.config' ) ;
21
- const aliasBuilder = require ( './alias-builder' ) ;
17
+ function outPath ( ) {
18
+ return skyPagesConfigUtil . outPath . apply ( skyPagesConfigUtil , arguments ) ;
19
+ }
22
20
21
+ function getWebpackConfig ( skyPagesConfig , argv ) {
23
22
const runCoverage = ( ! argv || argv . coverage !== false ) ;
24
23
skyPagesConfig . runtime . includeRouteModule = false ;
25
24
26
25
const ENV = process . env . ENV = process . env . NODE_ENV = 'test' ;
27
26
const srcPath = path . resolve ( process . cwd ( ) , 'src' , 'app' ) ;
28
- const moduleLoader = outPath ( 'loader' , 'sky-pages-module' ) ;
29
27
30
28
const resolves = [
31
29
process . cwd ( ) ,
@@ -53,7 +51,7 @@ function getWebpackConfig(skyPagesConfig, argv) {
53
51
extensions : [
54
52
'.js' ,
55
53
'.ts'
56
- ] ,
54
+ ]
57
55
} ,
58
56
59
57
module : {
@@ -66,17 +64,7 @@ function getWebpackConfig(skyPagesConfig, argv) {
66
64
{
67
65
enforce : 'pre' ,
68
66
test : / s k y - p a g e s \. m o d u l e \. t s $ / ,
69
- loader : moduleLoader
70
- } ,
71
- {
72
- enforce : 'pre' ,
73
- test : / \. t s $ / ,
74
- loader : 'tslint-loader' ,
75
- exclude : excludes ,
76
- options : {
77
- emitErrors : true ,
78
- failOnHint : true
79
- }
67
+ loader : outPath ( 'loader' , 'sky-pages-module' )
80
68
} ,
81
69
{
82
70
enforce : 'pre' ,
@@ -87,7 +75,13 @@ function getWebpackConfig(skyPagesConfig, argv) {
87
75
{
88
76
enforce : 'pre' ,
89
77
loader : outPath ( 'loader' , 'sky-processor' , 'preload' ) ,
90
- exclude : / n o d e _ m o d u l e s /
78
+ exclude : excludes
79
+ } ,
80
+ {
81
+ enforce : 'pre' ,
82
+ test : / \. t s $ / ,
83
+ loader : outPath ( 'loader' , 'sky-tslint' ) ,
84
+ exclude : excludes
91
85
} ,
92
86
{
93
87
test : / \. t s $ / ,
@@ -98,7 +92,9 @@ function getWebpackConfig(skyPagesConfig, argv) {
98
92
// Ignore the "Cannot find module" error that occurs when referencing
99
93
// an aliased file. Webpack will still throw an error when a module
100
94
// cannot be resolved via a file path or alias.
101
- ignoreDiagnostics : [ 2307 ]
95
+ ignoreDiagnostics : [ 2307 ] ,
96
+ // Linting is handled by the sky-tslint loader.
97
+ transpileOnly : true
102
98
}
103
99
} ,
104
100
{
@@ -108,19 +104,12 @@ function getWebpackConfig(skyPagesConfig, argv) {
108
104
exclude : [ / \. e 2 e \. t s $ / ]
109
105
} ,
110
106
{
111
- test : / \. c s s $ / ,
112
- loader : 'raw-loader'
107
+ test : / \. s ? c s s $ / ,
108
+ use : [ 'raw-loader' , 'sass-loader' ]
113
109
} ,
114
110
{
115
111
test : / \. h t m l $ / ,
116
112
loader : 'raw-loader'
117
- } ,
118
- {
119
- test : / \. s c s s $ / ,
120
- use : [
121
- 'raw-loader' ,
122
- 'sass-loader'
123
- ]
124
113
}
125
114
]
126
115
} ,
@@ -130,13 +119,7 @@ function getWebpackConfig(skyPagesConfig, argv) {
130
119
debug : true ,
131
120
options : {
132
121
context : __dirname ,
133
- skyPagesConfig : skyPagesConfig ,
134
- tslint : {
135
- emitErrors : false ,
136
- failOnHint : false ,
137
- resourcePath : 'src' ,
138
- typeCheck : true
139
- }
122
+ skyPagesConfig : skyPagesConfig
140
123
}
141
124
} ) ,
142
125
@@ -154,11 +137,14 @@ function getWebpackConfig(skyPagesConfig, argv) {
154
137
155
138
new ContextReplacementPlugin (
156
139
// The (\\|\/) piece accounts for path separators in *nix and Windows
157
- / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) ( e s m ( \\ | \/ ) s r c | s r c ) ( \\ | \/ ) l i n k e r / ,
158
- skyPagesConfigUtil . spaPath ( 'src' ) , // location of your src
140
+ / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) @ a n g u l a r / ,
141
+ skyPagesConfigUtil . spaPath ( 'src' ) ,
159
142
{ }
160
143
) ,
161
144
145
+ // Handles watch-mode maintenance for TSLint.
146
+ new SkyTsLintCheckerPlugin ( ) ,
147
+
162
148
// Webpack 2 behavior does not correctly return non-zero exit code.
163
149
new ProcessExitCode ( )
164
150
]
0 commit comments