@zthun/janitor-build-config 19.2.0 → 19.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vite.cjs CHANGED
@@ -1,20 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("@vitejs/plugin-react");
4
- const lodashEs = require("lodash-es");
5
- const swc = require("unplugin-swc");
6
- const vitePluginChecker = require("vite-plugin-checker");
7
- const dtsPlugin = require("vite-plugin-dts");
8
- const vitePluginExternalizeDeps = require("vite-plugin-externalize-deps");
9
- const tsConfigPaths = require("vite-tsconfig-paths");
10
- class ZViteLibraryBuilder {
11
- constructor() {
12
- this.library = {
13
- entry: {},
14
- formats: ["es", "cjs"]
15
- };
16
- }
17
- /**
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const react = require('@vitejs/plugin-react');
6
+ const lodashEs = require('lodash-es');
7
+ const swc = require('unplugin-swc');
8
+ const vitePluginChecker = require('vite-plugin-checker');
9
+ const dtsPlugin = require('vite-plugin-dts');
10
+ const vitePluginExternalizeDeps = require('vite-plugin-externalize-deps');
11
+ const tsConfigPaths = require('vite-tsconfig-paths');
12
+
13
+ function _define_property$3(obj, key, value) {
14
+ if (key in obj) {
15
+ Object.defineProperty(obj, key, {
16
+ value: value,
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true
20
+ });
21
+ } else {
22
+ obj[key] = value;
23
+ }
24
+ return obj;
25
+ }
26
+ function _object_spread$2(target) {
27
+ for(var i = 1; i < arguments.length; i++){
28
+ var source = arguments[i] != null ? arguments[i] : {};
29
+ var ownKeys = Object.keys(source);
30
+ if (typeof Object.getOwnPropertySymbols === "function") {
31
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
32
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
33
+ }));
34
+ }
35
+ ownKeys.forEach(function(key) {
36
+ _define_property$3(target, key, source[key]);
37
+ });
38
+ }
39
+ return target;
40
+ }
41
+ function ownKeys$2(object, enumerableOnly) {
42
+ var keys = Object.keys(object);
43
+ if (Object.getOwnPropertySymbols) {
44
+ var symbols = Object.getOwnPropertySymbols(object);
45
+ keys.push.apply(keys, symbols);
46
+ }
47
+ return keys;
48
+ }
49
+ function _object_spread_props$2(target, source) {
50
+ source = source != null ? source : {};
51
+ if (Object.getOwnPropertyDescriptors) {
52
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
53
+ } else {
54
+ ownKeys$2(Object(source)).forEach(function(key) {
55
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
56
+ });
57
+ }
58
+ return target;
59
+ }
60
+ /**
61
+ * A builder for Vite library configurations.
62
+ */ class ZViteLibraryBuilder {
63
+ /**
18
64
  * Adds an entry point to the library.
19
65
  *
20
66
  * @param name -
@@ -24,53 +70,91 @@ class ZViteLibraryBuilder {
24
70
  *
25
71
  * @returns
26
72
  * This object.
27
- */
28
- entry(name, path) {
29
- this.library.entry = {
30
- ...this.library.entry,
31
- [name]: path
32
- };
33
- return this;
34
- }
35
- /**
73
+ */ entry(name, path) {
74
+ this.library.entry = _object_spread_props$2(_object_spread$2({}, this.library.entry), {
75
+ [name]: path
76
+ });
77
+ return this;
78
+ }
79
+ /**
36
80
  * A shorthand for adding an entry point
37
81
  * named "index" that points to "src/index.ts"
38
82
  *
39
83
  * @returns
40
84
  * This object.
41
- */
42
- index() {
43
- return this.entry("index", "./src/index.mts");
44
- }
45
- /**
85
+ */ index() {
86
+ return this.entry("index", "./src/index.mts");
87
+ }
88
+ /**
46
89
  * Returns the built library configuration.
47
90
  *
48
91
  * @returns
49
92
  * A deep clone of the library configuration.
50
- */
51
- build() {
52
- return lodashEs.cloneDeep(this.library);
53
- }
93
+ */ build() {
94
+ return lodashEs.cloneDeep(this.library);
95
+ }
96
+ constructor(){
97
+ _define_property$3(this, "library", {
98
+ entry: {},
99
+ formats: [
100
+ "es",
101
+ "cjs"
102
+ ]
103
+ });
104
+ }
54
105
  }
55
- class ZViteTestBuilder {
56
- /**
57
- * Initializes a new instance of this object.
58
- */
59
- constructor() {
60
- this.node = this.environment.bind(this, "node");
61
- this.browser = this.environment.bind(this, "happy-dom");
62
- this.v8 = this.coverage.bind(this, "v8");
63
- this.istanbul = this.coverage.bind(this, "istanbul");
64
- this.test = {
65
- environment: "node",
66
- testTimeout: 3e4,
67
- coverage: {
68
- all: false,
69
- provider: void 0
70
- }
71
- };
72
- }
73
- /**
106
+
107
+ function _define_property$2(obj, key, value) {
108
+ if (key in obj) {
109
+ Object.defineProperty(obj, key, {
110
+ value: value,
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true
114
+ });
115
+ } else {
116
+ obj[key] = value;
117
+ }
118
+ return obj;
119
+ }
120
+ function _object_spread$1(target) {
121
+ for(var i = 1; i < arguments.length; i++){
122
+ var source = arguments[i] != null ? arguments[i] : {};
123
+ var ownKeys = Object.keys(source);
124
+ if (typeof Object.getOwnPropertySymbols === "function") {
125
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
126
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
127
+ }));
128
+ }
129
+ ownKeys.forEach(function(key) {
130
+ _define_property$2(target, key, source[key]);
131
+ });
132
+ }
133
+ return target;
134
+ }
135
+ function ownKeys$1(object, enumerableOnly) {
136
+ var keys = Object.keys(object);
137
+ if (Object.getOwnPropertySymbols) {
138
+ var symbols = Object.getOwnPropertySymbols(object);
139
+ keys.push.apply(keys, symbols);
140
+ }
141
+ return keys;
142
+ }
143
+ function _object_spread_props$1(target, source) {
144
+ source = source != null ? source : {};
145
+ if (Object.getOwnPropertyDescriptors) {
146
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
147
+ } else {
148
+ ownKeys$1(Object(source)).forEach(function(key) {
149
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
150
+ });
151
+ }
152
+ return target;
153
+ }
154
+ /**
155
+ * A builder for test configurations found in vite's defineConfig test field.
156
+ */ class ZViteTestBuilder {
157
+ /**
74
158
  * Sets the test environment.
75
159
  *
76
160
  * @param environment -
@@ -78,12 +162,11 @@ class ZViteTestBuilder {
78
162
  *
79
163
  * @returns
80
164
  * This object.
81
- */
82
- environment(environment) {
83
- this.test.environment = environment;
84
- return this;
85
- }
86
- /**
165
+ */ environment(environment) {
166
+ this.test.environment = environment;
167
+ return this;
168
+ }
169
+ /**
87
170
  * Sets the test coverage provider.
88
171
  *
89
172
  * @param provider -
@@ -91,12 +174,13 @@ class ZViteTestBuilder {
91
174
  *
92
175
  * @returns
93
176
  * This object.
94
- */
95
- coverage(provider) {
96
- this.test.coverage = { ...this.test.coverage, provider };
97
- return this;
98
- }
99
- /**
177
+ */ coverage(provider) {
178
+ this.test.coverage = _object_spread_props$1(_object_spread$1({}, this.test.coverage), {
179
+ provider
180
+ });
181
+ return this;
182
+ }
183
+ /**
100
184
  * Adds to the list of projects.
101
185
  *
102
186
  * @param project -
@@ -104,13 +188,12 @@ class ZViteTestBuilder {
104
188
  *
105
189
  * @returns
106
190
  * This object.
107
- */
108
- project(project = []) {
109
- const projects = this.test.projects || [];
110
- this.test.projects = projects.concat(project);
111
- return this;
112
- }
113
- /**
191
+ */ project(project = []) {
192
+ const projects = this.test.projects || [];
193
+ this.test.projects = projects.concat(project);
194
+ return this;
195
+ }
196
+ /**
114
197
  * Adds monorepo support to the test builder.
115
198
  *
116
199
  * @param packages -
@@ -118,35 +201,144 @@ class ZViteTestBuilder {
118
201
  *
119
202
  * @returns
120
203
  * This object.
121
- */
122
- monorepo(packages = "packages") {
123
- return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);
124
- }
125
- /**
204
+ */ monorepo(packages = "packages") {
205
+ return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);
206
+ }
207
+ /**
126
208
  * Returns the built test configuration.
127
209
  *
128
210
  * @returns
129
211
  * A deep clone of the test configuration.
130
- */
131
- build() {
132
- return lodashEs.cloneDeep(this.test);
133
- }
134
- }
135
- class ZViteConfigBuilder {
136
- /**
212
+ */ build() {
213
+ return lodashEs.cloneDeep(this.test);
214
+ }
215
+ /**
137
216
  * Initializes a new instance of this object.
138
- */
139
- constructor() {
140
- this.lodash = this.alias.bind(this, "lodash", "lodash-es");
141
- this.config = {
142
- build: {
143
- minify: true,
144
- sourcemap: false
145
- },
146
- plugins: [tsConfigPaths()]
147
- };
148
- }
149
- /**
217
+ */ constructor(){
218
+ _define_property$2(this, "test", void 0);
219
+ /**
220
+ * Sets the test environment to "node".
221
+ *
222
+ * @returns
223
+ * This object.
224
+ */ _define_property$2(this, "node", this.environment.bind(this, "node"));
225
+ /**
226
+ * Sets the test environment to "happy-dom".
227
+ *
228
+ * @returns
229
+ * This object.
230
+ */ _define_property$2(this, "browser", this.environment.bind(this, "happy-dom"));
231
+ /**
232
+ * Sets the test coverage provider to "v8".
233
+ *
234
+ * @returns
235
+ * This object.
236
+ */ _define_property$2(this, "v8", this.coverage.bind(this, "v8"));
237
+ /**
238
+ * Sets the test coverage provider to "istanbul".
239
+ *
240
+ * @returns
241
+ * This object.
242
+ */ _define_property$2(this, "istanbul", this.coverage.bind(this, "istanbul"));
243
+ this.test = {
244
+ environment: "node",
245
+ testTimeout: 30000,
246
+ coverage: {
247
+ all: false,
248
+ provider: "v8"
249
+ }
250
+ };
251
+ }
252
+ }
253
+
254
+ function _define_property$1(obj, key, value) {
255
+ if (key in obj) {
256
+ Object.defineProperty(obj, key, {
257
+ value: value,
258
+ enumerable: true,
259
+ configurable: true,
260
+ writable: true
261
+ });
262
+ } else {
263
+ obj[key] = value;
264
+ }
265
+ return obj;
266
+ }
267
+ function _object_spread(target) {
268
+ for(var i = 1; i < arguments.length; i++){
269
+ var source = arguments[i] != null ? arguments[i] : {};
270
+ var ownKeys = Object.keys(source);
271
+ if (typeof Object.getOwnPropertySymbols === "function") {
272
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
273
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
274
+ }));
275
+ }
276
+ ownKeys.forEach(function(key) {
277
+ _define_property$1(target, key, source[key]);
278
+ });
279
+ }
280
+ return target;
281
+ }
282
+ function ownKeys(object, enumerableOnly) {
283
+ var keys = Object.keys(object);
284
+ if (Object.getOwnPropertySymbols) {
285
+ var symbols = Object.getOwnPropertySymbols(object);
286
+ keys.push.apply(keys, symbols);
287
+ }
288
+ return keys;
289
+ }
290
+ function _object_spread_props(target, source) {
291
+ source = source != null ? source : {};
292
+ if (Object.getOwnPropertyDescriptors) {
293
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
294
+ } else {
295
+ ownKeys(Object(source)).forEach(function(key) {
296
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
297
+ });
298
+ }
299
+ return target;
300
+ }
301
+ /**
302
+ * A config builder for the vite build system.
303
+ *
304
+ * This is helpful when building different types
305
+ * of projects and keeping a standard.
306
+ *
307
+ * @example vite.config.ts
308
+ *
309
+ * ```ts
310
+ * // Before Config Builder
311
+ * export default defineConfig({
312
+ * build: {
313
+ * lib: {
314
+ * entry: {
315
+ * index: "./src/index.ts",
316
+ * },
317
+ * formats: ["cjs", "es"],
318
+ * },
319
+ * },
320
+ * minify: false,
321
+ * sourceMap: true,
322
+ * plugins: [
323
+ * swc.vite(),
324
+ * tsConfigPaths(),
325
+ * externalizeDeps(),
326
+ * dtsPlugin({
327
+ * compilerOptions: {
328
+ * paths: {},
329
+ * },
330
+ * }),
331
+ * ],
332
+ * });
333
+ * ```
334
+ *
335
+ * ```ts
336
+ * // After config builder
337
+ * const config = new ZViteConfigBuilder().library().build();
338
+ * export default defineConfig(config);
339
+ * ```
340
+ */ class ZViteConfigBuilder {
341
+ /**
150
342
  * Sets whether to minify the build output.
151
343
  *
152
344
  * @param minify -
@@ -154,12 +346,13 @@ class ZViteConfigBuilder {
154
346
  *
155
347
  * @returns
156
348
  * This object.
157
- */
158
- minify(minify = true) {
159
- this.config.build = { ...this.config.build, minify };
160
- return this;
161
- }
162
- /**
349
+ */ minify(minify = true) {
350
+ this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
351
+ minify
352
+ });
353
+ return this;
354
+ }
355
+ /**
163
356
  * Adds a list of plugins.
164
357
  *
165
358
  * @param option -
@@ -167,22 +360,14 @@ class ZViteConfigBuilder {
167
360
  *
168
361
  * @returns
169
362
  * This object.
170
- */
171
- plugin(option = []) {
172
- const plugins = this.config.plugins;
173
- this.config.plugins = plugins.concat(lodashEs.castArray(option));
174
- return this;
175
- }
176
- /**
177
- * Adds the swc plugin.
178
- *
179
- * This is mostly for nest projects as nest requires
180
- * swc to support decorators.
181
- */
182
- swc() {
183
- return this.plugin(swc.vite());
184
- }
185
- /**
363
+ */ plugin(option = []) {
364
+ // See constructor - the config plugins are guaranteed to
365
+ // be set. The swc and paths plugins are automatically added.
366
+ const plugins = this.config.plugins;
367
+ this.config.plugins = plugins.concat(lodashEs.castArray(option));
368
+ return this;
369
+ }
370
+ /**
186
371
  * Sets whether to generate source maps.
187
372
  *
188
373
  * @param sourcemap -
@@ -190,12 +375,13 @@ class ZViteConfigBuilder {
190
375
  *
191
376
  * @returns
192
377
  * This object.
193
- */
194
- sourceMap(sourcemap = true) {
195
- this.config.build = { ...this.config.build, sourcemap };
196
- return this;
197
- }
198
- /**
378
+ */ sourceMap(sourcemap = true) {
379
+ this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
380
+ sourcemap
381
+ });
382
+ return this;
383
+ }
384
+ /**
199
385
  * Adds an alias to the resolution options.
200
386
  *
201
387
  * @param key -
@@ -205,14 +391,13 @@ class ZViteConfigBuilder {
205
391
  *
206
392
  * @returns
207
393
  * This object.
208
- */
209
- alias(key, value) {
210
- this.config.resolve = this.config.resolve || {};
211
- this.config.resolve.alias = this.config.resolve.alias || {};
212
- this.config.resolve.alias[key] = value;
213
- return this;
214
- }
215
- /**
394
+ */ alias(key, value) {
395
+ this.config.resolve = this.config.resolve || {};
396
+ this.config.resolve.alias = this.config.resolve.alias || {};
397
+ this.config.resolve.alias[key] = value;
398
+ return this;
399
+ }
400
+ /**
216
401
  * Assigns the server options.
217
402
  *
218
403
  * @param options -
@@ -220,12 +405,11 @@ class ZViteConfigBuilder {
220
405
  *
221
406
  * @returns
222
407
  * This object.
223
- */
224
- server(options) {
225
- this.config.server = lodashEs.cloneDeep(options);
226
- return this;
227
- }
228
- /**
408
+ */ server(options) {
409
+ this.config.server = lodashEs.cloneDeep(options);
410
+ return this;
411
+ }
412
+ /**
229
413
  * Sets vite into library mode.
230
414
  *
231
415
  * @param lib -
@@ -237,37 +421,42 @@ class ZViteConfigBuilder {
237
421
  *
238
422
  * @returns
239
423
  * This object.
240
- */
241
- library(lib = new ZViteLibraryBuilder().index().build()) {
242
- this.config.build = { ...this.config.build, lib };
243
- const dts = dtsPlugin({
244
- compilerOptions: {
245
- // Always turn off paths when building for production. You want to make
246
- // sure that your build is building in the correct order and that your
247
- // actual paths are correct.
248
- paths: {}
249
- }
250
- });
251
- const external = vitePluginExternalizeDeps.externalizeDeps();
252
- return this.minify(false).sourceMap().plugin(external).plugin(dts);
253
- }
254
- /**
424
+ */ library(lib = new ZViteLibraryBuilder().index().build()) {
425
+ this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
426
+ lib
427
+ });
428
+ const dts = dtsPlugin({
429
+ compilerOptions: {
430
+ // Always turn off paths when building for production. You want to make
431
+ // sure that your build is building in the correct order and that your
432
+ // actual paths are correct.
433
+ paths: {}
434
+ },
435
+ // Make sure to exclude spec and test files.
436
+ exclude: [
437
+ "**/*.{spec,test}.{js,mjs,cjs,ts,mts,jsx,tsx}"
438
+ ]
439
+ });
440
+ const external = vitePluginExternalizeDeps.externalizeDeps();
441
+ return this.minify(false).sourceMap().plugin(external).plugin(dts);
442
+ }
443
+ /**
255
444
  * Constructs the config to act as if it's compiling a node application.
256
445
  *
257
446
  * This is just an alias to {@link ZViteConfigBuilder.library} with two
258
447
  * entry points.
259
448
  *
260
449
  * 1. The file src/cli.ts is the main entry point of the application.
261
- * 1. The file, src/index.ts, is the api for importing
450
+ * 1. The file, src/index.ts, is the api for importing and using it as an api.
262
451
  *
263
452
  * @returns
264
453
  * This object.
265
- */
266
- cli() {
267
- const library = new ZViteLibraryBuilder().entry("index", "src/index.mts").entry("cli", "src/cli.mts").build();
268
- return this.library(library);
269
- }
270
- /**
454
+ */ cli() {
455
+ // A cli works similar to a library.
456
+ const library = new ZViteLibraryBuilder().entry("index", "src/index.mts").entry("cli", "src/cli.mts").build();
457
+ return this.library(library);
458
+ }
459
+ /**
271
460
  * Constructs the config to act as if it's compiling a nest application.
272
461
  *
273
462
  * This is just an alias to {@link ZViteConfigBuilder.library} with a single
@@ -277,89 +466,130 @@ class ZViteConfigBuilder {
277
466
  *
278
467
  * @returns
279
468
  * This object.
280
- */
281
- nest() {
282
- const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
283
- return this.library(library).swc();
284
- }
285
- /**
469
+ */ nest() {
470
+ const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
471
+ return this.library(library);
472
+ }
473
+ /**
286
474
  * Constructs the config to act as if it's compiling a web application.
287
475
  *
288
476
  * @returns
289
477
  * This object.
290
- */
291
- web() {
292
- return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({ typescript: true }));
293
- }
294
- /**
478
+ */ web() {
479
+ return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({
480
+ typescript: true
481
+ }));
482
+ }
483
+ /**
295
484
  * Constructs the config to compile a react application.
296
485
  *
297
486
  * @returns
298
487
  * This object.
299
- */
300
- react() {
301
- return this.web().plugin(react());
302
- }
303
- /**
488
+ */ react() {
489
+ return this.web().plugin(react());
490
+ }
491
+ /**
304
492
  * Constructs the config to be for testing.
305
493
  *
306
494
  * @param options -
307
495
  * The test config to use. If this is falsy,
308
- * then a test setup using a monorepo with an
309
- * istanbul provider in node is used.
310
- */
311
- test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
312
- this.config.test = options;
313
- return this;
314
- }
315
- /**
496
+ * then a test setup using a monorepo with the default
497
+ * provider and environment will be used.
498
+ */ test(options = new ZViteTestBuilder().monorepo().build()) {
499
+ this.config.test = options;
500
+ return this;
501
+ }
502
+ /**
316
503
  * Returns the currently built config.
317
504
  *
318
505
  * @returns
319
506
  * The currently built config.
320
- */
321
- build() {
322
- return lodashEs.cloneDeep(this.config);
323
- }
507
+ */ build() {
508
+ return lodashEs.cloneDeep(this.config);
509
+ }
510
+ /**
511
+ * Initializes a new instance of this object.
512
+ */ constructor(){
513
+ _define_property$1(this, "config", void 0);
514
+ /**
515
+ * Adds an alias for lodash to lodash-es.
516
+ *
517
+ * @returns
518
+ * This object.
519
+ */ _define_property$1(this, "lodash", this.alias.bind(this, "lodash", "lodash-es"));
520
+ this.config = {
521
+ build: {
522
+ minify: true,
523
+ sourcemap: false
524
+ },
525
+ plugins: [
526
+ swc.vite({
527
+ jsc: {
528
+ transform: {
529
+ react: {
530
+ runtime: "automatic"
531
+ }
532
+ }
533
+ }
534
+ }),
535
+ tsConfigPaths()
536
+ ]
537
+ };
538
+ }
539
+ }
540
+
541
+ function _define_property(obj, key, value) {
542
+ if (key in obj) {
543
+ Object.defineProperty(obj, key, {
544
+ value: value,
545
+ enumerable: true,
546
+ configurable: true,
547
+ writable: true
548
+ });
549
+ } else {
550
+ obj[key] = value;
551
+ }
552
+ return obj;
324
553
  }
325
554
  class ZViteServerBuilder {
326
- constructor() {
327
- this.options = {};
328
- this.localhost = this.host.bind(this, "127.0.0.1");
329
- }
330
- allowedHost(name) {
331
- if (name === true) {
332
- this.options.allowedHosts = true;
333
- } else if (this.options.allowedHosts !== true) {
334
- const hosts = this.options.allowedHosts || [];
335
- this.options.allowedHosts = hosts.concat(name);
336
- }
337
- return this;
338
- }
339
- denyAllHosts() {
340
- delete this.options.allowedHosts;
341
- return this;
342
- }
343
- port(port) {
344
- this.options.port = port;
345
- return this;
346
- }
347
- strictPort() {
348
- this.options.strictPort = true;
349
- return this;
350
- }
351
- host(ip) {
352
- this.options.host = ip;
353
- return this;
354
- }
355
- dev() {
356
- return this.strictPort().host("0.0.0.0").allowedHost(true);
357
- }
358
- build() {
359
- const clone = lodashEs.cloneDeep(this.options);
360
- return lodashEs.omitBy(clone, lodashEs.isUndefined);
361
- }
555
+ allowedHost(name) {
556
+ if (name === true) {
557
+ this.options.allowedHosts = true;
558
+ } else if (this.options.allowedHosts !== true) {
559
+ const hosts = this.options.allowedHosts || [];
560
+ this.options.allowedHosts = hosts.concat(name);
561
+ }
562
+ return this;
563
+ }
564
+ denyAllHosts() {
565
+ delete this.options.allowedHosts;
566
+ return this;
567
+ }
568
+ port(port) {
569
+ this.options.port = port;
570
+ return this;
571
+ }
572
+ strictPort() {
573
+ this.options.strictPort = true;
574
+ return this;
575
+ }
576
+ host(ip) {
577
+ this.options.host = ip;
578
+ return this;
579
+ }
580
+ dev() {
581
+ return this.strictPort().host("0.0.0.0").allowedHost(true);
582
+ }
583
+ build() {
584
+ const clone = lodashEs.cloneDeep(this.options);
585
+ return lodashEs.omitBy(clone, lodashEs.isUndefined);
586
+ }
587
+ constructor(){
588
+ _define_property(this, "options", {});
589
+ _define_property(this, "localhost", this.host.bind(this, "127.0.0.1"));
590
+ }
362
591
  }
592
+
363
593
  exports.ZViteConfigBuilder = ZViteConfigBuilder;
364
594
  exports.ZViteLibraryBuilder = ZViteLibraryBuilder;
365
595
  exports.ZViteServerBuilder = ZViteServerBuilder;