unplugin-https-reverse-proxy 1.0.0-beta.8 → 1.0.0-beta.9
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/README.md +85 -1
- package/dist/{chunk-AYUGOY4B.js → chunk-ZSHTX2B6.js} +43 -8
- package/dist/esbuild.cjs +43 -8
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +43 -8
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +5 -5
- package/dist/nuxt.js +1 -1
- package/dist/rollup.cjs +43 -8
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +643 -0
- package/dist/rspack.d.cts +5 -0
- package/dist/rspack.d.ts +5 -0
- package/dist/rspack.js +10 -0
- package/dist/vite.cjs +43 -8
- package/dist/vite.d.cts +1 -2
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +43 -8
- package/dist/webpack.js +1 -1
- package/package.json +37 -21
- package/src/index.ts +48 -2
- package/src/rspack.ts +5 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/unplugin-https-reverse-proxy)
|
|
4
4
|
|
|
5
|
-
A plugin for https reverse proxy, support `vite` and `
|
|
5
|
+
A plugin for https reverse proxy, support `vite`、`webpack` and `rspack`.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -124,6 +124,90 @@ module.exports = {
|
|
|
124
124
|
|
|
125
125
|
<br></details>
|
|
126
126
|
|
|
127
|
+
<details>
|
|
128
|
+
<summary>Rspack</summary><br>
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// rspack.config.js
|
|
132
|
+
|
|
133
|
+
/** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
|
|
134
|
+
const reverseProxyOptions = {
|
|
135
|
+
enable: false,
|
|
136
|
+
target: 'xxx',
|
|
137
|
+
https: false,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = {
|
|
141
|
+
/* ... */
|
|
142
|
+
devServer: {
|
|
143
|
+
client: {
|
|
144
|
+
// ↓ for HMR
|
|
145
|
+
webSocketURL: {
|
|
146
|
+
...(reverseProxyOptions.enable
|
|
147
|
+
? {
|
|
148
|
+
hostname: reverseProxyOptions.target,
|
|
149
|
+
}
|
|
150
|
+
: {}),
|
|
151
|
+
...(reverseProxyOptions.enable && reverseProxyOptions.https
|
|
152
|
+
? {
|
|
153
|
+
protocol: 'wss',
|
|
154
|
+
port: 443,
|
|
155
|
+
}
|
|
156
|
+
: {})
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
plugins: [
|
|
161
|
+
require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
<br></details>
|
|
167
|
+
|
|
168
|
+
<details>
|
|
169
|
+
<summary>Rsbuild</summary><br>
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
// rsbuild.config.js
|
|
173
|
+
|
|
174
|
+
/** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
|
|
175
|
+
const reverseProxyOptions = {
|
|
176
|
+
enable: false,
|
|
177
|
+
target: 'xxx',
|
|
178
|
+
https: false,
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
module.exports = {
|
|
182
|
+
/* ... */
|
|
183
|
+
dev: {
|
|
184
|
+
client: {
|
|
185
|
+
// ↓ for HMR
|
|
186
|
+
...(reverseProxyOptions.enable
|
|
187
|
+
? {
|
|
188
|
+
host: reverseProxyOptions.target,
|
|
189
|
+
}
|
|
190
|
+
: {}),
|
|
191
|
+
...(reverseProxyOptions.enable && reverseProxyOptions.https
|
|
192
|
+
? {
|
|
193
|
+
protocol: 'wss',
|
|
194
|
+
port: '443',
|
|
195
|
+
}
|
|
196
|
+
: {})
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
tools: {
|
|
200
|
+
rspack: {
|
|
201
|
+
plugins: [
|
|
202
|
+
require('unplugin-https-reverse-proxy/rspack')(reverseProxyOptions)
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
<br></details>
|
|
210
|
+
|
|
127
211
|
<details>
|
|
128
212
|
<summary>Nuxt</summary><br>
|
|
129
213
|
|
|
@@ -374,14 +374,14 @@ var CaddyInstant = class {
|
|
|
374
374
|
const port = Number(source.split(":")[1]);
|
|
375
375
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
376
376
|
await kill(port, "tcp");
|
|
377
|
-
const
|
|
378
|
-
const viteCacheDir = `${
|
|
377
|
+
const pwd = process3.cwd();
|
|
378
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
379
379
|
if (existsSync(viteCacheDir))
|
|
380
380
|
chmodRecursive(viteCacheDir, 511);
|
|
381
|
-
const nuxtCacheDir = `${
|
|
381
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
382
382
|
if (existsSync(nuxtCacheDir))
|
|
383
383
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
384
|
-
const webpackCacheDir = `${
|
|
384
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
385
385
|
if (existsSync(webpackCacheDir))
|
|
386
386
|
chmodRecursive(webpackCacheDir, 511);
|
|
387
387
|
if (!restore || this.stoped)
|
|
@@ -422,7 +422,7 @@ var CaddyInstant = class {
|
|
|
422
422
|
// src/index.ts
|
|
423
423
|
var config;
|
|
424
424
|
var caddy;
|
|
425
|
-
var
|
|
425
|
+
var cwd = process4.cwd();
|
|
426
426
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
427
427
|
_printUrls == null ? void 0 : _printUrls();
|
|
428
428
|
if (caddy)
|
|
@@ -474,7 +474,7 @@ var unpluginFactory = (options) => ({
|
|
|
474
474
|
}
|
|
475
475
|
},
|
|
476
476
|
webpack(compiler) {
|
|
477
|
-
var _a;
|
|
477
|
+
var _a, _b;
|
|
478
478
|
if (process4.env.NODE_ENV !== "development")
|
|
479
479
|
return;
|
|
480
480
|
if (!isAdmin()) {
|
|
@@ -494,11 +494,11 @@ var unpluginFactory = (options) => ({
|
|
|
494
494
|
const devServer = __spreadValues(__spreadValues({
|
|
495
495
|
host: "localhost",
|
|
496
496
|
port: 8080
|
|
497
|
-
}, compiler.options.devServer), process4.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
497
|
+
}, compiler.options.devServer), (_a = process4.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
498
498
|
const source = `${devServer.host}:${devServer.port}`;
|
|
499
499
|
if (caddy)
|
|
500
500
|
return;
|
|
501
|
-
const _close = (
|
|
501
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
502
502
|
if (_close) {
|
|
503
503
|
compiler.close = async (callback) => {
|
|
504
504
|
process4.on("exit", () => {
|
|
@@ -517,6 +517,41 @@ var unpluginFactory = (options) => ({
|
|
|
517
517
|
}).catch((e) => {
|
|
518
518
|
throw e;
|
|
519
519
|
});
|
|
520
|
+
},
|
|
521
|
+
async rspack(compiler) {
|
|
522
|
+
var _a, _b, _c;
|
|
523
|
+
if (process4.env.NODE_ENV !== "development")
|
|
524
|
+
return;
|
|
525
|
+
if (!isAdmin()) {
|
|
526
|
+
consola.warn("please run as administrator");
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const {
|
|
530
|
+
enable = true,
|
|
531
|
+
target = ""
|
|
532
|
+
} = options;
|
|
533
|
+
if (!enable)
|
|
534
|
+
return;
|
|
535
|
+
if (!target) {
|
|
536
|
+
consola.fail("please provide target");
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const devServer = __spreadValues(__spreadValues({
|
|
540
|
+
host: "localhost",
|
|
541
|
+
port: 8080
|
|
542
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
543
|
+
cwd
|
|
544
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
545
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
546
|
+
if (caddy)
|
|
547
|
+
return;
|
|
548
|
+
caddy = new CaddyInstant();
|
|
549
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
550
|
+
const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
551
|
+
consola.success(` ${c.green("\u279C")} ${c.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
552
|
+
}).catch((e) => {
|
|
553
|
+
throw e;
|
|
554
|
+
});
|
|
520
555
|
}
|
|
521
556
|
});
|
|
522
557
|
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/esbuild.cjs
CHANGED
|
@@ -456,14 +456,14 @@ var CaddyInstant = class {
|
|
|
456
456
|
const port = Number(source.split(":")[1]);
|
|
457
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
458
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
459
|
-
const
|
|
460
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
461
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
462
462
|
chmodRecursive(viteCacheDir, 511);
|
|
463
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
464
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
465
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
466
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
467
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
468
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
469
469
|
if (!restore || this.stoped)
|
|
@@ -504,7 +504,7 @@ var CaddyInstant = class {
|
|
|
504
504
|
// src/index.ts
|
|
505
505
|
var config;
|
|
506
506
|
var caddy;
|
|
507
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
508
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
509
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
510
510
|
if (caddy)
|
|
@@ -556,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
558
|
webpack(compiler) {
|
|
559
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
560
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
561
561
|
return;
|
|
562
562
|
if (!isAdmin()) {
|
|
@@ -576,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
576
576
|
const devServer = __spreadValues(__spreadValues({
|
|
577
577
|
host: "localhost",
|
|
578
578
|
port: 8080
|
|
579
|
-
}, compiler.options.devServer), import_node_process5.default.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
579
|
+
}, compiler.options.devServer), (_a = import_node_process5.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
580
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
581
581
|
if (caddy)
|
|
582
582
|
return;
|
|
583
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
584
584
|
if (_close) {
|
|
585
585
|
compiler.close = async (callback) => {
|
|
586
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -599,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
599
599
|
}).catch((e) => {
|
|
600
600
|
throw e;
|
|
601
601
|
});
|
|
602
|
+
},
|
|
603
|
+
async rspack(compiler) {
|
|
604
|
+
var _a, _b, _c;
|
|
605
|
+
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
606
|
+
return;
|
|
607
|
+
if (!isAdmin()) {
|
|
608
|
+
consola.warn("please run as administrator");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const {
|
|
612
|
+
enable = true,
|
|
613
|
+
target = ""
|
|
614
|
+
} = options;
|
|
615
|
+
if (!enable)
|
|
616
|
+
return;
|
|
617
|
+
if (!target) {
|
|
618
|
+
consola.fail("please provide target");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const devServer = __spreadValues(__spreadValues({
|
|
622
|
+
host: "localhost",
|
|
623
|
+
port: 8080
|
|
624
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
625
|
+
cwd
|
|
626
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
627
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
628
|
+
if (caddy)
|
|
629
|
+
return;
|
|
630
|
+
caddy = new CaddyInstant();
|
|
631
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
632
|
+
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
633
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
634
|
+
}).catch((e) => {
|
|
635
|
+
throw e;
|
|
636
|
+
});
|
|
602
637
|
}
|
|
603
638
|
});
|
|
604
639
|
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -456,14 +456,14 @@ var CaddyInstant = class {
|
|
|
456
456
|
const port = Number(source.split(":")[1]);
|
|
457
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
458
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
459
|
-
const
|
|
460
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
461
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
462
462
|
chmodRecursive(viteCacheDir, 511);
|
|
463
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
464
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
465
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
466
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
467
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
468
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
469
469
|
if (!restore || this.stoped)
|
|
@@ -504,7 +504,7 @@ var CaddyInstant = class {
|
|
|
504
504
|
// src/index.ts
|
|
505
505
|
var config;
|
|
506
506
|
var caddy;
|
|
507
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
508
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
509
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
510
510
|
if (caddy)
|
|
@@ -556,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
558
|
webpack(compiler) {
|
|
559
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
560
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
561
561
|
return;
|
|
562
562
|
if (!isAdmin()) {
|
|
@@ -576,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
576
576
|
const devServer = __spreadValues(__spreadValues({
|
|
577
577
|
host: "localhost",
|
|
578
578
|
port: 8080
|
|
579
|
-
}, compiler.options.devServer), import_node_process5.default.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
579
|
+
}, compiler.options.devServer), (_a = import_node_process5.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
580
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
581
581
|
if (caddy)
|
|
582
582
|
return;
|
|
583
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
584
584
|
if (_close) {
|
|
585
585
|
compiler.close = async (callback) => {
|
|
586
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -599,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
599
599
|
}).catch((e) => {
|
|
600
600
|
throw e;
|
|
601
601
|
});
|
|
602
|
+
},
|
|
603
|
+
async rspack(compiler) {
|
|
604
|
+
var _a, _b, _c;
|
|
605
|
+
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
606
|
+
return;
|
|
607
|
+
if (!isAdmin()) {
|
|
608
|
+
consola.warn("please run as administrator");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const {
|
|
612
|
+
enable = true,
|
|
613
|
+
target = ""
|
|
614
|
+
} = options;
|
|
615
|
+
if (!enable)
|
|
616
|
+
return;
|
|
617
|
+
if (!target) {
|
|
618
|
+
consola.fail("please provide target");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const devServer = __spreadValues(__spreadValues({
|
|
622
|
+
host: "localhost",
|
|
623
|
+
port: 8080
|
|
624
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
625
|
+
cwd
|
|
626
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
627
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
628
|
+
if (caddy)
|
|
629
|
+
return;
|
|
630
|
+
caddy = new CaddyInstant();
|
|
631
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
632
|
+
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
633
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
634
|
+
}).catch((e) => {
|
|
635
|
+
throw e;
|
|
636
|
+
});
|
|
602
637
|
}
|
|
603
638
|
});
|
|
604
639
|
var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -458,14 +458,14 @@ var CaddyInstant = class {
|
|
|
458
458
|
const port = Number(source.split(":")[1]);
|
|
459
459
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
460
460
|
await (0, import_kill_port.default)(port, "tcp");
|
|
461
|
-
const
|
|
462
|
-
const viteCacheDir = `${
|
|
461
|
+
const pwd = import_node_process4.default.cwd();
|
|
462
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
463
463
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
464
464
|
chmodRecursive(viteCacheDir, 511);
|
|
465
|
-
const nuxtCacheDir = `${
|
|
465
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
466
466
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
467
467
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
468
|
-
const webpackCacheDir = `${
|
|
468
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
469
469
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
470
470
|
chmodRecursive(webpackCacheDir, 511);
|
|
471
471
|
if (!restore || this.stoped)
|
|
@@ -505,7 +505,7 @@ var CaddyInstant = class {
|
|
|
505
505
|
|
|
506
506
|
// src/index.ts
|
|
507
507
|
var caddy;
|
|
508
|
-
var
|
|
508
|
+
var cwd = import_node_process5.default.cwd();
|
|
509
509
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
510
510
|
_printUrls == null ? void 0 : _printUrls();
|
|
511
511
|
if (caddy)
|
package/dist/nuxt.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -456,14 +456,14 @@ var CaddyInstant = class {
|
|
|
456
456
|
const port = Number(source.split(":")[1]);
|
|
457
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
458
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
459
|
-
const
|
|
460
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
461
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
462
462
|
chmodRecursive(viteCacheDir, 511);
|
|
463
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
464
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
465
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
466
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
467
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
468
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
469
469
|
if (!restore || this.stoped)
|
|
@@ -504,7 +504,7 @@ var CaddyInstant = class {
|
|
|
504
504
|
// src/index.ts
|
|
505
505
|
var config;
|
|
506
506
|
var caddy;
|
|
507
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
508
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
509
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
510
510
|
if (caddy)
|
|
@@ -556,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
558
|
webpack(compiler) {
|
|
559
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
560
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
561
561
|
return;
|
|
562
562
|
if (!isAdmin()) {
|
|
@@ -576,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
576
576
|
const devServer = __spreadValues(__spreadValues({
|
|
577
577
|
host: "localhost",
|
|
578
578
|
port: 8080
|
|
579
|
-
}, compiler.options.devServer), import_node_process5.default.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
579
|
+
}, compiler.options.devServer), (_a = import_node_process5.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
580
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
581
581
|
if (caddy)
|
|
582
582
|
return;
|
|
583
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
584
584
|
if (_close) {
|
|
585
585
|
compiler.close = async (callback) => {
|
|
586
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -599,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
599
599
|
}).catch((e) => {
|
|
600
600
|
throw e;
|
|
601
601
|
});
|
|
602
|
+
},
|
|
603
|
+
async rspack(compiler) {
|
|
604
|
+
var _a, _b, _c;
|
|
605
|
+
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
606
|
+
return;
|
|
607
|
+
if (!isAdmin()) {
|
|
608
|
+
consola.warn("please run as administrator");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const {
|
|
612
|
+
enable = true,
|
|
613
|
+
target = ""
|
|
614
|
+
} = options;
|
|
615
|
+
if (!enable)
|
|
616
|
+
return;
|
|
617
|
+
if (!target) {
|
|
618
|
+
consola.fail("please provide target");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const devServer = __spreadValues(__spreadValues({
|
|
622
|
+
host: "localhost",
|
|
623
|
+
port: 8080
|
|
624
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
625
|
+
cwd
|
|
626
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
627
|
+
const source = `${devServer.host}:${devServer.port}`;
|
|
628
|
+
if (caddy)
|
|
629
|
+
return;
|
|
630
|
+
caddy = new CaddyInstant();
|
|
631
|
+
caddy.run(source, target, __spreadValues({}, options)).then(() => {
|
|
632
|
+
const colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
633
|
+
consola.success(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold("run caddy reverse proxy success")}: ${colorUrl(`${options.https ? "https" : "http"}://${target}`)}`);
|
|
634
|
+
}).catch((e) => {
|
|
635
|
+
throw e;
|
|
636
|
+
});
|
|
602
637
|
}
|
|
603
638
|
});
|
|
604
639
|
|