@@ -134,10 +134,7 @@ module.exports = {
134
134
},
135
135
};
136
136
137
- ```
138
-
139
- > Advanced custom configuration :
140
- ``` js
137
+ // Advanced custom configuration :
141
138
// find more example in unittest, please
142
139
module .exports = (app , defaultConfig , dev , target ) => {
143
140
const factory = app .webpackFactory ;
@@ -192,8 +189,12 @@ module.exports = (app, defaultConfig, dev, target) => {
192
189
};
193
190
194
191
```
195
- > Class Plugin Struct
196
- ```
192
+
193
+ #### Class Struct
194
+
195
+ > Class Struct for Plugin
196
+
197
+ ``` js
197
198
class Plugin {
198
199
object , // instance object for webpack plugin
199
200
class , // class for webpack plugin
@@ -203,14 +204,74 @@ class Plugin {
203
204
204
205
```
205
206
206
- > Class Rule Struct
207
- ```
207
+ > Class Struct for Rule
208
+
209
+ ``` js
208
210
class Rule {
209
211
opitons, // initialize config for rule
210
212
alias
211
213
}
212
214
213
215
```
216
+
217
+ ## Webpackfactory
218
+
219
+ ##### Define Custom Loader:
220
+ ``` js
221
+ app .webpackFactory .defineLoader ({
222
+ ' babel-loader' ,
223
+ require .resolve (' babel-loader' )
224
+ })
225
+ ```
226
+
227
+ ##### Define Custom Rule:
228
+ ``` js
229
+ app .webpackFactory .defineRule ({
230
+ test: / \. tsx? $ / ,
231
+ exclude: / node_modules/ ,
232
+ use: {
233
+ loader: app .webpackFactory .useLoader (' babel-loader' ), // used the defined loader.
234
+ options: {
235
+ babelrc: false ,
236
+ presets: [' preset-typescript' ],
237
+ },
238
+ },
239
+ },' tsx' )
240
+ // add the rule config to webpack factory
241
+ app .webpackFactory .addRule (
242
+ app .webpackFactory .useRule (' tsx' )
243
+ )
244
+ // add the rule config to webpack factory
245
+ app .webpackFactory .getRule (' tsx' ); // return Rule Object
246
+ ```
247
+
248
+ ##### Define Custom Plugin:
249
+ ``` js
250
+ app .webpackFactory .definePlugin (webpack .NoEmitOnErrorsPlugin ,{},' NoEmitOnErrorsPlugin' )
251
+
252
+ // add defined plugin to webpack factory
253
+ app .webpackFactory .addPlugin (
254
+ app .webpackFactory .usePlugin (' NoEmitOnErrorsPlugin' )
255
+ )
256
+
257
+ // method 1:
258
+ app .webpackFactory .addPlugin (webpack .optimize .UglifyJsPlugin , {
259
+ compress: {
260
+ warnings: false ,
261
+ },
262
+ }, ' UglifyJsPlugin' )
263
+ // method 2:
264
+ app .webpackFactory .addPlugin (
265
+ new webpack.optimize.UglifyJsPlugin ({
266
+ compress: {
267
+ warnings: false ,
268
+ },
269
+ })
270
+ )
271
+
272
+ ```
273
+
274
+
214
275
> app.webpackFactory methods list:
215
276
216
277
### reset(value)
0 commit comments