1
1
/*jslint node: true */
2
2
'use strict' ;
3
3
4
+ const logger = require ( '@blackbaud/skyux-logger' ) ;
4
5
const webpack = require ( 'webpack' ) ;
5
6
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
6
- const ProgressBarPlugin = require ( 'progress-bar -webpack-plugin' ) ;
7
+ const SimpleProgressWebpackPlugin = require ( 'simple-progress -webpack-plugin' ) ;
7
8
const LoaderOptionsPlugin = require ( 'webpack/lib/LoaderOptionsPlugin' ) ;
8
9
const CommonsChunkPlugin = require ( 'webpack/lib/optimize/CommonsChunkPlugin' ) ;
9
10
const ContextReplacementPlugin = require ( 'webpack/lib/ContextReplacementPlugin' ) ;
@@ -20,6 +21,18 @@ function outPath() {
20
21
return skyPagesConfigUtil . outPath . apply ( skyPagesConfigUtil , arguments ) ;
21
22
}
22
23
24
+ function getLogFormat ( skyPagesConfig , argv ) {
25
+ if ( argv . hasOwnProperty ( 'logFormat' ) ) {
26
+ return argv . logFormat ;
27
+ }
28
+
29
+ if ( skyPagesConfig . runtime . command === 'serve' || argv . serve ) {
30
+ return 'compact' ;
31
+ }
32
+
33
+ return 'expanded' ;
34
+ }
35
+
23
36
/**
24
37
* Called when loaded via require.
25
38
* @name getWebpackConfig
@@ -36,6 +49,8 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
36
49
let alias = aliasBuilder . buildAliasList ( skyPagesConfig ) ;
37
50
38
51
const outConfigMode = skyPagesConfig && skyPagesConfig . skyux && skyPagesConfig . skyux . mode ;
52
+ const logFormat = getLogFormat ( skyPagesConfig , argv ) ;
53
+
39
54
let appPath ;
40
55
41
56
switch ( outConfigMode ) {
@@ -48,6 +63,53 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
48
63
break ;
49
64
}
50
65
66
+ let plugins = [
67
+ // Some properties are required on the root object passed to HtmlWebpackPlugin
68
+ new HtmlWebpackPlugin ( {
69
+ template : skyPagesConfig . runtime . app . template ,
70
+ inject : skyPagesConfig . runtime . app . inject ,
71
+ runtime : skyPagesConfig . runtime ,
72
+ skyux : skyPagesConfig . skyux
73
+ } ) ,
74
+
75
+ new CommonsChunkPlugin ( {
76
+ name : [ 'skyux' , 'vendor' , 'polyfills' ]
77
+ } ) ,
78
+
79
+ new webpack . DefinePlugin ( {
80
+ 'skyPagesConfig' : JSON . stringify ( skyPagesConfig )
81
+ } ) ,
82
+
83
+ new LoaderOptionsPlugin ( {
84
+ options : {
85
+ context : __dirname ,
86
+ skyPagesConfig : skyPagesConfig
87
+ }
88
+ } ) ,
89
+
90
+ new ContextReplacementPlugin (
91
+ // The (\\|\/) piece accounts for path separators in *nix and Windows
92
+ / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) @ a n g u l a r / ,
93
+ spaPath ( 'src' ) ,
94
+ { }
95
+ ) ,
96
+
97
+ // Webpack 2 behavior does not correctly return non-zero exit code.
98
+ new ProcessExitCode ( ) ,
99
+
100
+ new OutputKeepAlivePlugin ( {
101
+ enabled : argv [ 'output-keep-alive' ]
102
+ } )
103
+ ] ;
104
+
105
+ // Supporting a custom logging type of none
106
+ if ( logFormat !== 'none' ) {
107
+ plugins . push ( new SimpleProgressWebpackPlugin ( {
108
+ format : logFormat ,
109
+ color : logger . logColor
110
+ } ) ) ;
111
+ }
112
+
51
113
return {
52
114
entry : {
53
115
polyfills : [ outPath ( 'src' , 'polyfills.ts' ) ] ,
@@ -111,46 +173,7 @@ function getWebpackConfig(skyPagesConfig, argv = {}) {
111
173
}
112
174
]
113
175
} ,
114
- plugins : [
115
- // Some properties are required on the root object passed to HtmlWebpackPlugin
116
- new HtmlWebpackPlugin ( {
117
- template : skyPagesConfig . runtime . app . template ,
118
- inject : skyPagesConfig . runtime . app . inject ,
119
- runtime : skyPagesConfig . runtime ,
120
- skyux : skyPagesConfig . skyux
121
- } ) ,
122
-
123
- new CommonsChunkPlugin ( {
124
- name : [ 'skyux' , 'vendor' , 'polyfills' ]
125
- } ) ,
126
-
127
- new webpack . DefinePlugin ( {
128
- 'skyPagesConfig' : JSON . stringify ( skyPagesConfig )
129
- } ) ,
130
-
131
- new ProgressBarPlugin ( ) ,
132
-
133
- new LoaderOptionsPlugin ( {
134
- options : {
135
- context : __dirname ,
136
- skyPagesConfig : skyPagesConfig
137
- }
138
- } ) ,
139
-
140
- new ContextReplacementPlugin (
141
- // The (\\|\/) piece accounts for path separators in *nix and Windows
142
- / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) @ a n g u l a r / ,
143
- spaPath ( 'src' ) ,
144
- { }
145
- ) ,
146
-
147
- // Webpack 2 behavior does not correctly return non-zero exit code.
148
- new ProcessExitCode ( ) ,
149
-
150
- new OutputKeepAlivePlugin ( {
151
- enabled : argv [ 'output-keep-alive' ]
152
- } )
153
- ]
176
+ plugins
154
177
} ;
155
178
}
156
179
0 commit comments