-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.packerrc.js
419 lines (380 loc) · 10.7 KB
/
.packerrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
/**
* Packer base configuration object.
*/
module.exports = {
/**
* Extend with packer base config
* @type {string}
* @default '~/packer-cli/resources/static/.packerrc.base.js'
*/
extend: '~/packer-cli/resources/static/.packerrc.base.js',
/**
* Entry source file.
* @type {string}
* @default 'index.js'
*/
entry: 'index.ts',
/**
* Source directory.
* @type {string}
* @default 'src'
*/
source: 'src',
/**
* Build artifact output directory
* @type {string}
* @default 'dist'
*/
dist: 'dist',
/**
* Watch and build temporary file directory
* @type {string}
* @default '.tmp'
*/
tmp: '.tmp',
/**
* Packer compiler options
*/
compiler: {
/**
* Dependency map mode option in target package.json file.
* - 'cross-map-peer-dependency' : Map project dependencies to target peerDependencies
* - 'cross-map-dependency' : Map project peerDependencies to target dependencies
* - 'map-dependency' : Map project dependencies to target dependencies
* - 'map-peer-dependency' : Map project peer dependencies to target peerDependencies
* - 'all' - Map both peerDependencies and dependencies to target peerDependencies and dependencies
* @type {string}
* @default 'cross-map-peer-dependency'
*/
dependencyMapMode: 'map-dependency',
/**
* Specified package fields will be copied to target package.json file.
* @type {Array<string>}
* @default [ 'name', 'version', 'description', 'keywords', 'author', 'repository', 'license', 'bugs', 'homepage' ]
*/
packageFieldsToCopy: [
'name',
'version',
'description',
'keywords',
'author',
'repository',
'license',
'bugs',
'homepage'
],
/**
* If true, a separate sourcemap file will be created. If inline, the sourcemap will be appended to
* the resulting output file as a data URI.
* @type {(boolean|string)}
* @default true
*/
sourceMap: true,
/**
* Custom rollup plugin extractor callback.
* @callback customRollupPluginExtractorCallback
* @param {string} buildType - 'bundle'|'es5'|'esnext'
* @param {string} packerConfig - Packer configuration object.
* @return {Array<{}>} Custom rollup plugin collection
*/
/**
* Extract custom rollup plugins to be executed while building the target artifacts.
* @type {(null|customRollupPluginExtractorCallback)}
*/
customRollupPluginExtractor: null,
/**
* Compile build target config.
* @type {{}}
* @default {}
*/
build: {
/**
* Generate flat bundle minified build artifact.
* @type {boolean}
* @default true
*/
bundleMin: false,
/**
* Generate flat es5 build artifact based on .babelrc es5 environment configuration.
* @type {boolean}
* @default false
*/
es5: false,
/**
* Generate flat es5 minified build artifact.
* @type {boolean}
* @default false
*/
es5Min: false,
/**
* Generate flat esnext build artifact based on .babelrc esnext environment configuration.
* @type {boolean}
* @default true
*/
esnext: false,
/**
* Generate flat esnext minified build artifact.
* @type {boolean}
* @default true
*/
esnextMin: false
},
/**
* Library compile mode.
* - 'browser' : Browser/NodeJS compliant module.
* - 'node' : NodeJS only module.
* - 'node-cli' : Node CLI module.
* @type {string}
* @default 'browser'
*/
buildMode: 'node-cli',
/**
* Script compile configuration.
* @type {{}}
* @default {}
*/
script: {
/**
* Script preprocessor.
* - 'typescript' : use typescript preprocessor to transpile source.
* - 'none': do not use any script preprocessor to transpile source.
* @type {string}
* @default 'none'
*/
preprocessor: 'typescript',
/**
* Directory to copy typescript typescript definition files of target build if typescript preprocessor is used.
* Path relative to dist directory. Empty string denote copy to distribution root.
* @type {string}
* @default 'typings'
*/
tsd: 'typings',
/**
* Script required image compile configuration.
* set false if not required to inline images
* @type {({}|false)}
* @default {}
*/
image: {
/**
* Inline image if image size is less than or equal to specified limit.
* @type {number}
* @default 1000000
*/
inlineLimit: 1000000,
/**
* Large image output directory within distribution directory.
* @type {string}
* @default 'images'
*/
outDir: 'images'
}
},
/**
* Style compile configuration.
* Set false if styles are not supported.
* @type {({}|false)}
* @default {}
*/
style: false,
/**
* Run bundle build tasks concurrently to improve performance if true
* @type {boolean}
* @default true
*/
concurrentBuild: true
},
/**
* List of paths which contains static assets referenced in style sheets.
* Paths should be relative to project root.
* @type {Array<string>}
* @default []
*/
assetPaths: [],
/**
* List of files paths to copy on build.
* Paths should be relative to project root.
* @type {Array<string>}
* @default [ 'README.md', 'LICENSE' ]
*/
copy: ['README.md', 'LICENSE', 'resources/**/{.*,*}', 'docs/**/{.*,*}'],
/**
* Prevent a module from showing up in the output bundle. You will get export default {} instead.
* @type {Array<string>}
* @default []
*/
ignore: [],
/**
* Custom rollup plugin extractor callback.
* @callback pathReplaceCallback
* @param {string} code - code segment
* @param {string} id - file path/identifier.
* @return {string} transformed code.
*/
/**
* Path Replace pattern object type.
* @typedef {Object} PathReplacePattern
* @property {(string|RegExp)} test - test expression or string.
* @property {string} replace - string to replace the match.
* @property {RegExp} match - regexp match with resolved path.
* @property {(string|string[])} include - whitelist patterns to match.
* @property {(string|string[])} exclude - blacklist patterns avoid matching.
* @property {string} text - replace content with given text.
* @property {string} file - replace with given file relative to project root.
* @property {pathReplaceCallback} transform - path replace function.
*/
/**
* Import path replace pattern collection.
* @type {Array<PathReplacePattern>}
* @default []
*/
replacePatterns: [],
/**
* Bundle artifact build configuration.
* @type {{}}
*/
bundle: {
/**
* Bundle output external dependencies (dependency modules to treat as externals).
* Refer rollup options for more info.
* @type {Array<string>}
* @default []
*/
externals: [
'@babel/**',
'rollup',
'rollup-plugin-*',
'@rollup/**',
'karma-rollup-preprocessor',
'chalk',
'glob-to-regexp',
'gulp',
'gulp-*',
'handlebars',
'inquirer',
'lodash*',
'plugin-error',
'schema-inspector',
'through2',
'validate-npm-package-name',
'validator/**',
'path',
'fs',
'child_process',
'terser',
'chokidar'
],
/**
* Bundle output global dependencies (dependency modules to tread as globals).
* Refer rollup options for more info.
* @type {{}}
* @default {}
*/
globals: {},
/**
* Treat globals as externals if true
* @type {boolean}
* @default true
*/
mapExternals: false,
/**
* Browser compliant bundle modules formats (based on .babelrc bundle environment configuration)
* - 'umd' – Universal Module Definition, works as amd, cjs and iife all in one
* - 'amd' – Asynchronous Module Definition, used with module loaders like RequireJS
* - 'iife' – A self-executing function, suitable for inclusion as a DOM script tag. (If you want to create a bundle
* for your application, you probably want to use this, because it leads to smaller file sizes.)
* - 'system' - Native format of SystemJS loader
*
* NodeJS only bundle module formats
* 'cjs' – CommonJS, suitable for Node and Browserify/Webpack
* 'esm' – Keep the bundle as an ES module file
* @type {string}
* @default 'umd'
*/
format: 'cjs',
/**
* Library global scope namespace (only applicable for browser compliant).
* @type {string}
* @default 'com.lib'
*/
namespace: '',
/**
* AMD flat bundle configuration
* @type {{}}
* @default {}
*/
amd: {
/**
* AMD flat bundle define function name
* @type {string}
* @default ''
*/
define: '',
/**
* AMD flat bundle module identifier name
* @type {string}
* @default 'my-lib'
*/
id: ''
}
},
/**
* Unit test configuration.
* @type {{}}
*/
test: {
/**
* Unit test framework
* - 'jasmine' - https://jasmine.github.io/
* - 'mocha' - https://mochajs.org/
* - 'jest' - https://jestjs.io/
* @type {string}
* @default 'jasmine'
*/
framework: 'jest',
/**
* Unit test environment.
* - 'node' - nodejs only unit test environment to test none browser compliant libraries.
* - 'browser' - browser based unit test environment with karma.
* - 'jsdom' - browser like unit test environment in nodejs with jsdom.
* - 'enzyme' - only supported when building react library with jest test framework.
* @type {string}
* @default 'node'
*/
environment: 'node'
},
/**
* Watch mode serve configuration.
* Set false if not required to serve on watch build.
* @type {({}|false)}
* @default {}
*/
serve: false,
/**
* Bundle license configuration
* @type {{}}
* @default {}
*/
license: {
/**
* Include inline header banner parsed via .packer/.banner.hbs template to build artifacts.
* @type {boolean}
* @default true
*/
banner: true
},
/**
* Code auto format configuration.
* Auto format with https://prettier.io
* @type {{}}
* @default {}
*/
format: {
/**
* File extensions to auto format.
* @type {string[]}
* @default [ 'js', 'jsx', 'ts', 'tsx', 'html', 'scss', 'css', 'less', 'json' ]
*/
extensions: ['js', 'jsx', 'ts', 'tsx', 'html', 'scss', 'css', 'less', 'json']
}
};