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