@@ -9,16 +9,9 @@ const path = require('path'),
9
9
/**
10
10
* Webpack Plugins
11
11
*/
12
- const ContextReplacementPlugin = require ( 'webpack/lib/ContextReplacementPlugin' ) ;
13
- const DefinePlugin = require ( 'webpack/lib/DefinePlugin' ) ;
14
12
const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
15
13
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
16
- const IgnorePlugin = require ( 'webpack/lib/IgnorePlugin' ) ;
17
- const LoaderOptionsPlugin = require ( 'webpack/lib/LoaderOptionsPlugin' ) ;
18
- const NormalModuleReplacementPlugin = require ( 'webpack/lib/NormalModuleReplacementPlugin' ) ;
19
14
const OptimizeJsPlugin = require ( 'optimize-js-plugin' ) ;
20
- const ProvidePlugin = require ( 'webpack/lib/ProvidePlugin' ) ;
21
- const UglifyJsPlugin = require ( 'webpack/lib/optimize/UglifyJsPlugin' ) ;
22
15
23
16
// ExtractTextPlugin
24
17
const extractCSS = new ExtractTextPlugin ( {
@@ -41,57 +34,72 @@ module.exports = {
41
34
module : {
42
35
rules : [
43
36
{
44
- enforce : 'pre' ,
45
37
test : / \. t s $ / ,
38
+ enforce : 'pre' ,
46
39
use : 'tslint-loader' ,
47
40
exclude : [ helpers . root ( 'node_modules' ) ]
48
41
} ,
49
42
{
50
43
test : / \. t s $ / ,
51
44
use : [
52
- {
53
- loader : 'awesome-typescript-loader' ,
54
- options : {
55
- declaration : false
56
- }
57
- } ,
58
- {
59
- loader : 'angular2-template-loader'
60
- }
45
+ // 'awesome-typescript-loader',
46
+ 'ts-loader' ,
47
+ 'angular2-template-loader'
61
48
] ,
62
49
exclude : [ / \. s p e c \. t s $ / ]
63
- } , {
50
+ } ,
51
+
52
+ /*
53
+ * to string and css loader support for *.css files
54
+ * Returns file content as string
55
+ *
56
+ */
57
+ {
64
58
test : / \. c s s $ / ,
65
- loader : extractCSS . extract ( {
59
+ use : extractCSS . extract ( {
66
60
fallback : "style-loader" ,
67
- use : "css-loader?sourceMap&context=/"
61
+ use : [
62
+ {
63
+ loader : 'css-loader' ,
64
+ options : {
65
+ sourceMap : true ,
66
+ context : '/'
67
+ } ,
68
+ } ,
69
+ ]
68
70
} )
69
71
} ,
70
72
71
- /* File loader for supporting fonts, for example, in CSS files.
73
+ /**
74
+ * File loader for supporting fonts, for example, in CSS files.
72
75
*/
73
76
{
74
- test : / \. w o f f 2 ? $ | \. t t f $ | \. e o t $ | \. s v g $ / ,
75
- loaders : [
76
- {
77
- loader : "url-loader" ,
78
- query : {
79
- limit : 3000 ,
80
- name : 'assets/fonts/[name].[ext]'
81
- }
77
+ test : / \. ( w o f f 2 | w o f f | t t f | e o t | s v g ) $ / ,
78
+ use : {
79
+ loader : 'url-loader' ,
80
+ query : {
81
+ limit : 3000 ,
82
+ // includePaths: [
83
+ // path.resolve(__dirname, "../node_modules/patternfly/dist/fonts/")
84
+ // ],
85
+ name : 'assets/fonts/[name].[ext]'
82
86
}
83
- ]
84
- } , {
85
- test : / \. j p g $ | \. p n g $ | \. g i f $ | \. j p e g $ / ,
86
- loaders : [
87
- {
88
- loader : "url-loader" ,
89
- query : {
90
- limit : 3000 ,
91
- name : 'assets/fonts/[name].[ext]'
92
- }
87
+ } ,
88
+ exclude : path . resolve ( __dirname , "../src/demo/images/" )
89
+ } ,
90
+ {
91
+ test : / \. ( j p g | p n g | s v g | g i f | j p e g ) $ / ,
92
+ use : {
93
+ loader : 'url-loader' ,
94
+ query : {
95
+ limit : 3000 ,
96
+ includePaths : [
97
+ path . resolve ( __dirname , "../src/assets/images/" )
98
+ ] ,
99
+ name : 'assets/images/[name].[ext]'
93
100
}
94
- ]
101
+ } ,
102
+ exclude : path . resolve ( __dirname , "../node_modules/patternfly/dist/fonts/" )
95
103
} ,
96
104
97
105
// Support for *.json files.
@@ -108,6 +116,18 @@ module.exports = {
108
116
]
109
117
} ,
110
118
119
+ optimization : {
120
+ splitChunks : {
121
+ cacheGroups : {
122
+ commons : {
123
+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
124
+ name : "vendors" ,
125
+ chunks : "all"
126
+ }
127
+ }
128
+ }
129
+ } ,
130
+
111
131
plugins : [
112
132
/**
113
133
* Plugin: ContextReplacementPlugin
@@ -141,7 +161,6 @@ module.exports = {
141
161
*
142
162
* See: https://github.com/webpack/extract-text-webpack-plugin
143
163
*/
144
- // new ExtractTextPlugin('[name].[contenthash].css'),
145
164
new ExtractTextPlugin ( '[name].css' ) ,
146
165
147
166
new webpack . LoaderOptionsPlugin ( {
@@ -151,19 +170,6 @@ module.exports = {
151
170
*
152
171
* See: https://github.com/webpack/html-loader#advanced-options
153
172
*/
154
- // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
155
- // htmlLoader: {
156
- // minimize: true,
157
- // removeAttributeQuotes: false,
158
- // caseSensitive: true,
159
- // customAttrSurround: [
160
- // [/#/, /(?:)/],
161
- // [/\*/, /(?:)/],
162
- // [/\[?\(?/, /(?:)/]
163
- // ],
164
- // customAttrAssign: [/\)?\]?=/]
165
- // },
166
-
167
173
tslintLoader : {
168
174
emitErrors : false ,
169
175
failOnHint : false
@@ -174,20 +180,10 @@ module.exports = {
174
180
// Only emit files when there are no errors
175
181
new webpack . NoEmitOnErrorsPlugin ( ) ,
176
182
177
- // // Reference: http://webpack.github.io/docs/list-of-plugins.html#dedupeplugin
178
- // // Dedupe modules in the output
179
- // new webpack.optimize.DedupePlugin(),
180
-
181
183
// Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
182
184
// Minify all javascript, switch loaders to minimizing mode
183
185
// new webpack.optimize.UglifyJsPlugin({sourceMap: true, mangle: { keep_fnames: true }}),
184
186
185
- // Copy assets from the public folder
186
- // Reference: https://github.com/kevlened/copy-webpack-plugin
187
- // new CopyWebpackPlugin([{
188
- // from: helpers.root('src/public')
189
- // }]),
190
-
191
187
// Reference: https://github.com/johnagan/clean-webpack-plugin
192
188
// Removes the bundle folder before the build
193
189
new CleanWebpackPlugin ( [ 'bundles' ] , {
0 commit comments