unplugin-https-reverse-proxy 1.0.0-beta.7 → 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-IUFVJYJ5.js → chunk-ZSHTX2B6.js} +46 -9
- package/dist/esbuild.cjs +46 -9
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +46 -9
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +8 -6
- package/dist/nuxt.js +1 -1
- package/dist/rollup.cjs +46 -9
- 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 +46 -9
- package/dist/vite.d.cts +1 -2
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +46 -9
- package/dist/webpack.js +1 -1
- package/package.json +40 -24
- package/src/caddy/constants.ts +3 -1
- 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
|
|
|
@@ -73,7 +73,9 @@ import { join } from "path";
|
|
|
73
73
|
import os from "os";
|
|
74
74
|
import process2 from "process";
|
|
75
75
|
import dotenvFlow from "dotenv-flow";
|
|
76
|
-
dotenvFlow.config(
|
|
76
|
+
dotenvFlow.config({
|
|
77
|
+
silent: true
|
|
78
|
+
});
|
|
77
79
|
function resolvePath(path) {
|
|
78
80
|
if (path.startsWith("~"))
|
|
79
81
|
return join(os.homedir() || "", path.slice(1));
|
|
@@ -372,14 +374,14 @@ var CaddyInstant = class {
|
|
|
372
374
|
const port = Number(source.split(":")[1]);
|
|
373
375
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
374
376
|
await kill(port, "tcp");
|
|
375
|
-
const
|
|
376
|
-
const viteCacheDir = `${
|
|
377
|
+
const pwd = process3.cwd();
|
|
378
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
377
379
|
if (existsSync(viteCacheDir))
|
|
378
380
|
chmodRecursive(viteCacheDir, 511);
|
|
379
|
-
const nuxtCacheDir = `${
|
|
381
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
380
382
|
if (existsSync(nuxtCacheDir))
|
|
381
383
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
382
|
-
const webpackCacheDir = `${
|
|
384
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
383
385
|
if (existsSync(webpackCacheDir))
|
|
384
386
|
chmodRecursive(webpackCacheDir, 511);
|
|
385
387
|
if (!restore || this.stoped)
|
|
@@ -420,7 +422,7 @@ var CaddyInstant = class {
|
|
|
420
422
|
// src/index.ts
|
|
421
423
|
var config;
|
|
422
424
|
var caddy;
|
|
423
|
-
var
|
|
425
|
+
var cwd = process4.cwd();
|
|
424
426
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
425
427
|
_printUrls == null ? void 0 : _printUrls();
|
|
426
428
|
if (caddy)
|
|
@@ -472,7 +474,7 @@ var unpluginFactory = (options) => ({
|
|
|
472
474
|
}
|
|
473
475
|
},
|
|
474
476
|
webpack(compiler) {
|
|
475
|
-
var _a;
|
|
477
|
+
var _a, _b;
|
|
476
478
|
if (process4.env.NODE_ENV !== "development")
|
|
477
479
|
return;
|
|
478
480
|
if (!isAdmin()) {
|
|
@@ -492,11 +494,11 @@ var unpluginFactory = (options) => ({
|
|
|
492
494
|
const devServer = __spreadValues(__spreadValues({
|
|
493
495
|
host: "localhost",
|
|
494
496
|
port: 8080
|
|
495
|
-
}, compiler.options.devServer), process4.VUE_CLI_SERVICE.projectOptions.devServer);
|
|
497
|
+
}, compiler.options.devServer), (_a = process4.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
496
498
|
const source = `${devServer.host}:${devServer.port}`;
|
|
497
499
|
if (caddy)
|
|
498
500
|
return;
|
|
499
|
-
const _close = (
|
|
501
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
500
502
|
if (_close) {
|
|
501
503
|
compiler.close = async (callback) => {
|
|
502
504
|
process4.on("exit", () => {
|
|
@@ -515,6 +517,41 @@ var unpluginFactory = (options) => ({
|
|
|
515
517
|
}).catch((e) => {
|
|
516
518
|
throw e;
|
|
517
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
|
+
});
|
|
518
555
|
}
|
|
519
556
|
});
|
|
520
557
|
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/esbuild.cjs
CHANGED
|
@@ -155,7 +155,9 @@ var import_node_path2 = require("path");
|
|
|
155
155
|
var import_node_os = __toESM(require("os"), 1);
|
|
156
156
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
157
157
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
158
|
-
import_dotenv_flow.default.config(
|
|
158
|
+
import_dotenv_flow.default.config({
|
|
159
|
+
silent: true
|
|
160
|
+
});
|
|
159
161
|
function resolvePath(path2) {
|
|
160
162
|
if (path2.startsWith("~"))
|
|
161
163
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -454,14 +456,14 @@ var CaddyInstant = class {
|
|
|
454
456
|
const port = Number(source.split(":")[1]);
|
|
455
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
456
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
457
|
-
const
|
|
458
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
459
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
460
462
|
chmodRecursive(viteCacheDir, 511);
|
|
461
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
462
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
463
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
464
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
465
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
466
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
467
469
|
if (!restore || this.stoped)
|
|
@@ -502,7 +504,7 @@ var CaddyInstant = class {
|
|
|
502
504
|
// src/index.ts
|
|
503
505
|
var config;
|
|
504
506
|
var caddy;
|
|
505
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
506
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
507
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
508
510
|
if (caddy)
|
|
@@ -554,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
554
556
|
}
|
|
555
557
|
},
|
|
556
558
|
webpack(compiler) {
|
|
557
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
558
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
559
561
|
return;
|
|
560
562
|
if (!isAdmin()) {
|
|
@@ -574,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
574
576
|
const devServer = __spreadValues(__spreadValues({
|
|
575
577
|
host: "localhost",
|
|
576
578
|
port: 8080
|
|
577
|
-
}, 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);
|
|
578
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
579
581
|
if (caddy)
|
|
580
582
|
return;
|
|
581
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
582
584
|
if (_close) {
|
|
583
585
|
compiler.close = async (callback) => {
|
|
584
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -597,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
597
599
|
}).catch((e) => {
|
|
598
600
|
throw e;
|
|
599
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
|
+
});
|
|
600
637
|
}
|
|
601
638
|
});
|
|
602
639
|
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -155,7 +155,9 @@ var import_node_path2 = require("path");
|
|
|
155
155
|
var import_node_os = __toESM(require("os"), 1);
|
|
156
156
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
157
157
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
158
|
-
import_dotenv_flow.default.config(
|
|
158
|
+
import_dotenv_flow.default.config({
|
|
159
|
+
silent: true
|
|
160
|
+
});
|
|
159
161
|
function resolvePath(path2) {
|
|
160
162
|
if (path2.startsWith("~"))
|
|
161
163
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -454,14 +456,14 @@ var CaddyInstant = class {
|
|
|
454
456
|
const port = Number(source.split(":")[1]);
|
|
455
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
456
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
457
|
-
const
|
|
458
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
459
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
460
462
|
chmodRecursive(viteCacheDir, 511);
|
|
461
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
462
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
463
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
464
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
465
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
466
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
467
469
|
if (!restore || this.stoped)
|
|
@@ -502,7 +504,7 @@ var CaddyInstant = class {
|
|
|
502
504
|
// src/index.ts
|
|
503
505
|
var config;
|
|
504
506
|
var caddy;
|
|
505
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
506
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
507
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
508
510
|
if (caddy)
|
|
@@ -554,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
554
556
|
}
|
|
555
557
|
},
|
|
556
558
|
webpack(compiler) {
|
|
557
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
558
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
559
561
|
return;
|
|
560
562
|
if (!isAdmin()) {
|
|
@@ -574,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
574
576
|
const devServer = __spreadValues(__spreadValues({
|
|
575
577
|
host: "localhost",
|
|
576
578
|
port: 8080
|
|
577
|
-
}, 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);
|
|
578
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
579
581
|
if (caddy)
|
|
580
582
|
return;
|
|
581
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
582
584
|
if (_close) {
|
|
583
585
|
compiler.close = async (callback) => {
|
|
584
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -597,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
597
599
|
}).catch((e) => {
|
|
598
600
|
throw e;
|
|
599
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
|
+
});
|
|
600
637
|
}
|
|
601
638
|
});
|
|
602
639
|
var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -157,7 +157,9 @@ var import_node_path2 = require("path");
|
|
|
157
157
|
var import_node_os = __toESM(require("os"), 1);
|
|
158
158
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
159
159
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
160
|
-
import_dotenv_flow.default.config(
|
|
160
|
+
import_dotenv_flow.default.config({
|
|
161
|
+
silent: true
|
|
162
|
+
});
|
|
161
163
|
function resolvePath(path2) {
|
|
162
164
|
if (path2.startsWith("~"))
|
|
163
165
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -456,14 +458,14 @@ var CaddyInstant = class {
|
|
|
456
458
|
const port = Number(source.split(":")[1]);
|
|
457
459
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
458
460
|
await (0, import_kill_port.default)(port, "tcp");
|
|
459
|
-
const
|
|
460
|
-
const viteCacheDir = `${
|
|
461
|
+
const pwd = import_node_process4.default.cwd();
|
|
462
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
461
463
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
462
464
|
chmodRecursive(viteCacheDir, 511);
|
|
463
|
-
const nuxtCacheDir = `${
|
|
465
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
464
466
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
465
467
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
466
|
-
const webpackCacheDir = `${
|
|
468
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
467
469
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
468
470
|
chmodRecursive(webpackCacheDir, 511);
|
|
469
471
|
if (!restore || this.stoped)
|
|
@@ -503,7 +505,7 @@ var CaddyInstant = class {
|
|
|
503
505
|
|
|
504
506
|
// src/index.ts
|
|
505
507
|
var caddy;
|
|
506
|
-
var
|
|
508
|
+
var cwd = import_node_process5.default.cwd();
|
|
507
509
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
508
510
|
_printUrls == null ? void 0 : _printUrls();
|
|
509
511
|
if (caddy)
|
package/dist/nuxt.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -155,7 +155,9 @@ var import_node_path2 = require("path");
|
|
|
155
155
|
var import_node_os = __toESM(require("os"), 1);
|
|
156
156
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
157
157
|
var import_dotenv_flow = __toESM(require("dotenv-flow"), 1);
|
|
158
|
-
import_dotenv_flow.default.config(
|
|
158
|
+
import_dotenv_flow.default.config({
|
|
159
|
+
silent: true
|
|
160
|
+
});
|
|
159
161
|
function resolvePath(path2) {
|
|
160
162
|
if (path2.startsWith("~"))
|
|
161
163
|
return (0, import_node_path2.join)(import_node_os.default.homedir() || "", path2.slice(1));
|
|
@@ -454,14 +456,14 @@ var CaddyInstant = class {
|
|
|
454
456
|
const port = Number(source.split(":")[1]);
|
|
455
457
|
if (!Number.isNaN(port) && await tryPort(port))
|
|
456
458
|
await (0, import_kill_port.default)(port, "tcp");
|
|
457
|
-
const
|
|
458
|
-
const viteCacheDir = `${
|
|
459
|
+
const pwd = import_node_process4.default.cwd();
|
|
460
|
+
const viteCacheDir = `${pwd}/node_modules/.vite`;
|
|
459
461
|
if ((0, import_node_fs2.existsSync)(viteCacheDir))
|
|
460
462
|
chmodRecursive(viteCacheDir, 511);
|
|
461
|
-
const nuxtCacheDir = `${
|
|
463
|
+
const nuxtCacheDir = `${pwd}/.nuxt`;
|
|
462
464
|
if ((0, import_node_fs2.existsSync)(nuxtCacheDir))
|
|
463
465
|
await chmodRecursive(nuxtCacheDir, 511);
|
|
464
|
-
const webpackCacheDir = `${
|
|
466
|
+
const webpackCacheDir = `${pwd}/node_modules/.cache`;
|
|
465
467
|
if ((0, import_node_fs2.existsSync)(webpackCacheDir))
|
|
466
468
|
chmodRecursive(webpackCacheDir, 511);
|
|
467
469
|
if (!restore || this.stoped)
|
|
@@ -502,7 +504,7 @@ var CaddyInstant = class {
|
|
|
502
504
|
// src/index.ts
|
|
503
505
|
var config;
|
|
504
506
|
var caddy;
|
|
505
|
-
var
|
|
507
|
+
var cwd = import_node_process5.default.cwd();
|
|
506
508
|
var vitePrintUrls = once((options, source, target, base = "/", _printUrls) => {
|
|
507
509
|
_printUrls == null ? void 0 : _printUrls();
|
|
508
510
|
if (caddy)
|
|
@@ -554,7 +556,7 @@ var unpluginFactory = (options) => ({
|
|
|
554
556
|
}
|
|
555
557
|
},
|
|
556
558
|
webpack(compiler) {
|
|
557
|
-
var _a;
|
|
559
|
+
var _a, _b;
|
|
558
560
|
if (import_node_process5.default.env.NODE_ENV !== "development")
|
|
559
561
|
return;
|
|
560
562
|
if (!isAdmin()) {
|
|
@@ -574,11 +576,11 @@ var unpluginFactory = (options) => ({
|
|
|
574
576
|
const devServer = __spreadValues(__spreadValues({
|
|
575
577
|
host: "localhost",
|
|
576
578
|
port: 8080
|
|
577
|
-
}, 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);
|
|
578
580
|
const source = `${devServer.host}:${devServer.port}`;
|
|
579
581
|
if (caddy)
|
|
580
582
|
return;
|
|
581
|
-
const _close = (
|
|
583
|
+
const _close = (_b = compiler.close) == null ? void 0 : _b.bind(compiler);
|
|
582
584
|
if (_close) {
|
|
583
585
|
compiler.close = async (callback) => {
|
|
584
586
|
import_node_process5.default.on("exit", () => {
|
|
@@ -597,6 +599,41 @@ var unpluginFactory = (options) => ({
|
|
|
597
599
|
}).catch((e) => {
|
|
598
600
|
throw e;
|
|
599
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
|
+
});
|
|
600
637
|
}
|
|
601
638
|
});
|
|
602
639
|
|