@zthun/janitor-build-config 19.1.5 → 19.2.2

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,34 +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.config = {
141
- build: {
142
- minify: true,
143
- sourcemap: false
144
- },
145
- plugins: [tsConfigPaths()]
146
- };
147
- }
148
- /**
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: undefined
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
+ /**
149
342
  * Sets whether to minify the build output.
150
343
  *
151
344
  * @param minify -
@@ -153,12 +346,13 @@ class ZViteConfigBuilder {
153
346
  *
154
347
  * @returns
155
348
  * This object.
156
- */
157
- minify(minify = true) {
158
- this.config.build = { ...this.config.build, minify };
159
- return this;
160
- }
161
- /**
349
+ */ minify(minify = true) {
350
+ this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
351
+ minify
352
+ });
353
+ return this;
354
+ }
355
+ /**
162
356
  * Adds a list of plugins.
163
357
  *
164
358
  * @param option -
@@ -166,22 +360,14 @@ class ZViteConfigBuilder {
166
360
  *
167
361
  * @returns
168
362
  * This object.
169
- */
170
- plugin(option = []) {
171
- const plugins = this.config.plugins;
172
- this.config.plugins = plugins.concat(lodashEs.castArray(option));
173
- return this;
174
- }
175
- /**
176
- * Adds the swc plugin.
177
- *
178
- * This is mostly for nest projects as nest requires
179
- * swc to support decorators.
180
- */
181
- swc() {
182
- return this.plugin(swc.vite());
183
- }
184
- /**
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
+ /**
185
371
  * Sets whether to generate source maps.
186
372
  *
187
373
  * @param sourcemap -
@@ -189,12 +375,29 @@ class ZViteConfigBuilder {
189
375
  *
190
376
  * @returns
191
377
  * This object.
192
- */
193
- sourceMap(sourcemap = true) {
194
- this.config.build = { ...this.config.build, sourcemap };
195
- return this;
196
- }
197
- /**
378
+ */ sourceMap(sourcemap = true) {
379
+ this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
380
+ sourcemap
381
+ });
382
+ return this;
383
+ }
384
+ /**
385
+ * Adds an alias to the resolution options.
386
+ *
387
+ * @param key -
388
+ * The name of the package to alias
389
+ * @param value -
390
+ * The alias resolution
391
+ *
392
+ * @returns
393
+ * This object.
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
+ /**
198
401
  * Assigns the server options.
199
402
  *
200
403
  * @param options -
@@ -202,12 +405,11 @@ class ZViteConfigBuilder {
202
405
  *
203
406
  * @returns
204
407
  * This object.
205
- */
206
- server(options) {
207
- this.config.server = lodashEs.cloneDeep(options);
208
- return this;
209
- }
210
- /**
408
+ */ server(options) {
409
+ this.config.server = lodashEs.cloneDeep(options);
410
+ return this;
411
+ }
412
+ /**
211
413
  * Sets vite into library mode.
212
414
  *
213
415
  * @param lib -
@@ -219,37 +421,38 @@ class ZViteConfigBuilder {
219
421
  *
220
422
  * @returns
221
423
  * This object.
222
- */
223
- library(lib = new ZViteLibraryBuilder().index().build()) {
224
- this.config.build = { ...this.config.build, lib };
225
- const dts = dtsPlugin({
226
- compilerOptions: {
227
- // Always turn off paths when building for production. You want to make
228
- // sure that your build is building in the correct order and that your
229
- // actual paths are correct.
230
- paths: {}
231
- }
232
- });
233
- const external = vitePluginExternalizeDeps.externalizeDeps();
234
- return this.minify(false).sourceMap().plugin(external).plugin(dts);
235
- }
236
- /**
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
+ });
436
+ const external = vitePluginExternalizeDeps.externalizeDeps();
437
+ return this.minify(false).sourceMap().plugin(external).plugin(dts);
438
+ }
439
+ /**
237
440
  * Constructs the config to act as if it's compiling a node application.
238
441
  *
239
442
  * This is just an alias to {@link ZViteConfigBuilder.library} with two
240
443
  * entry points.
241
444
  *
242
445
  * 1. The file src/cli.ts is the main entry point of the application.
243
- * 1. The file, src/index.ts, is the api for importing
446
+ * 1. The file, src/index.ts, is the api for importing and using it as an api.
244
447
  *
245
448
  * @returns
246
449
  * This object.
247
- */
248
- cli() {
249
- const library = new ZViteLibraryBuilder().entry("index", "src/index.mts").entry("cli", "src/cli.mts").build();
250
- return this.library(library);
251
- }
252
- /**
450
+ */ cli() {
451
+ // A cli works similar to a library.
452
+ const library = new ZViteLibraryBuilder().entry("index", "src/index.mts").entry("cli", "src/cli.mts").build();
453
+ return this.library(library);
454
+ }
455
+ /**
253
456
  * Constructs the config to act as if it's compiling a nest application.
254
457
  *
255
458
  * This is just an alias to {@link ZViteConfigBuilder.library} with a single
@@ -259,89 +462,130 @@ class ZViteConfigBuilder {
259
462
  *
260
463
  * @returns
261
464
  * This object.
262
- */
263
- nest() {
264
- const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
265
- return this.library(library).swc();
266
- }
267
- /**
465
+ */ nest() {
466
+ const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
467
+ return this.library(library);
468
+ }
469
+ /**
268
470
  * Constructs the config to act as if it's compiling a web application.
269
471
  *
270
472
  * @returns
271
473
  * This object.
272
- */
273
- web() {
274
- return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({ typescript: true }));
275
- }
276
- /**
474
+ */ web() {
475
+ return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({
476
+ typescript: true
477
+ }));
478
+ }
479
+ /**
277
480
  * Constructs the config to compile a react application.
278
481
  *
279
482
  * @returns
280
483
  * This object.
281
- */
282
- react() {
283
- return this.web().plugin(react());
284
- }
285
- /**
484
+ */ react() {
485
+ return this.web().plugin(react());
486
+ }
487
+ /**
286
488
  * Constructs the config to be for testing.
287
489
  *
288
490
  * @param options -
289
491
  * The test config to use. If this is falsy,
290
492
  * then a test setup using a monorepo with an
291
493
  * istanbul provider in node is used.
292
- */
293
- test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
294
- this.config.test = options;
295
- return this;
296
- }
297
- /**
494
+ */ test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
495
+ this.config.test = options;
496
+ return this;
497
+ }
498
+ /**
298
499
  * Returns the currently built config.
299
500
  *
300
501
  * @returns
301
502
  * The currently built config.
302
- */
303
- build() {
304
- return lodashEs.cloneDeep(this.config);
305
- }
503
+ */ build() {
504
+ return lodashEs.cloneDeep(this.config);
505
+ }
506
+ /**
507
+ * Initializes a new instance of this object.
508
+ */ constructor(){
509
+ _define_property$1(this, "config", void 0);
510
+ /**
511
+ * Adds an alias for lodash to lodash-es.
512
+ *
513
+ * @returns
514
+ * This object.
515
+ */ _define_property$1(this, "lodash", this.alias.bind(this, "lodash", "lodash-es"));
516
+ this.config = {
517
+ build: {
518
+ minify: true,
519
+ sourcemap: false
520
+ },
521
+ plugins: [
522
+ swc.vite({
523
+ jsc: {
524
+ transform: {
525
+ react: {
526
+ runtime: "automatic"
527
+ }
528
+ }
529
+ }
530
+ }),
531
+ tsConfigPaths()
532
+ ]
533
+ };
534
+ }
535
+ }
536
+
537
+ function _define_property(obj, key, value) {
538
+ if (key in obj) {
539
+ Object.defineProperty(obj, key, {
540
+ value: value,
541
+ enumerable: true,
542
+ configurable: true,
543
+ writable: true
544
+ });
545
+ } else {
546
+ obj[key] = value;
547
+ }
548
+ return obj;
306
549
  }
307
550
  class ZViteServerBuilder {
308
- constructor() {
309
- this.options = {};
310
- this.localhost = this.host.bind(this, "127.0.0.1");
311
- }
312
- allowedHost(name) {
313
- if (name === true) {
314
- this.options.allowedHosts = true;
315
- } else if (this.options.allowedHosts !== true) {
316
- const hosts = this.options.allowedHosts || [];
317
- this.options.allowedHosts = hosts.concat(name);
318
- }
319
- return this;
320
- }
321
- denyAllHosts() {
322
- delete this.options.allowedHosts;
323
- return this;
324
- }
325
- port(port) {
326
- this.options.port = port;
327
- return this;
328
- }
329
- strictPort() {
330
- this.options.strictPort = true;
331
- return this;
332
- }
333
- host(ip) {
334
- this.options.host = ip;
335
- return this;
336
- }
337
- dev() {
338
- return this.strictPort().host("0.0.0.0").allowedHost(true);
339
- }
340
- build() {
341
- const clone = lodashEs.cloneDeep(this.options);
342
- return lodashEs.omitBy(clone, lodashEs.isUndefined);
343
- }
551
+ allowedHost(name) {
552
+ if (name === true) {
553
+ this.options.allowedHosts = true;
554
+ } else if (this.options.allowedHosts !== true) {
555
+ const hosts = this.options.allowedHosts || [];
556
+ this.options.allowedHosts = hosts.concat(name);
557
+ }
558
+ return this;
559
+ }
560
+ denyAllHosts() {
561
+ delete this.options.allowedHosts;
562
+ return this;
563
+ }
564
+ port(port) {
565
+ this.options.port = port;
566
+ return this;
567
+ }
568
+ strictPort() {
569
+ this.options.strictPort = true;
570
+ return this;
571
+ }
572
+ host(ip) {
573
+ this.options.host = ip;
574
+ return this;
575
+ }
576
+ dev() {
577
+ return this.strictPort().host("0.0.0.0").allowedHost(true);
578
+ }
579
+ build() {
580
+ const clone = lodashEs.cloneDeep(this.options);
581
+ return lodashEs.omitBy(clone, lodashEs.isUndefined);
582
+ }
583
+ constructor(){
584
+ _define_property(this, "options", {});
585
+ _define_property(this, "localhost", this.host.bind(this, "127.0.0.1"));
586
+ }
344
587
  }
588
+
345
589
  exports.ZViteConfigBuilder = ZViteConfigBuilder;
346
590
  exports.ZViteLibraryBuilder = ZViteLibraryBuilder;
347
591
  exports.ZViteServerBuilder = ZViteServerBuilder;