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/dist/vite.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/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/dist/webpack.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/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-https-reverse-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "1.0.0-beta.9",
|
|
5
|
+
"packageManager": "pnpm@8.15.3",
|
|
6
6
|
"description": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"import": "./dist/webpack.js",
|
|
37
37
|
"require": "./dist/webpack.cjs"
|
|
38
38
|
},
|
|
39
|
+
"./rspack": {
|
|
40
|
+
"types": "./dist/rspack.d.ts",
|
|
41
|
+
"import": "./dist/rspack.js",
|
|
42
|
+
"require": "./dist/rspack.cjs"
|
|
43
|
+
},
|
|
39
44
|
"./rollup": {
|
|
40
45
|
"types": "./dist/rollup.d.ts",
|
|
41
46
|
"import": "./dist/rollup.js",
|
|
@@ -77,6 +82,8 @@
|
|
|
77
82
|
"peerDependencies": {
|
|
78
83
|
"@nuxt/kit": "^3",
|
|
79
84
|
"@nuxt/schema": "^3",
|
|
85
|
+
"@rsbuild/core": "^0.4.3",
|
|
86
|
+
"@rspack/core": "^0.5.4",
|
|
80
87
|
"esbuild": "*",
|
|
81
88
|
"rollup": "^3",
|
|
82
89
|
"vite": ">=3",
|
|
@@ -86,6 +93,12 @@
|
|
|
86
93
|
"webpack": {
|
|
87
94
|
"optional": true
|
|
88
95
|
},
|
|
96
|
+
"@rspack/core": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@rsbuild/core": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
89
102
|
"rollup": {
|
|
90
103
|
"optional": true
|
|
91
104
|
},
|
|
@@ -107,33 +120,35 @@
|
|
|
107
120
|
"dotenv-flow": "^4.1.0",
|
|
108
121
|
"got-cjs": "^12.5.4",
|
|
109
122
|
"hosts-so-easy": "^1.2.9",
|
|
110
|
-
"http-proxy-agent": "^7.0.
|
|
111
|
-
"https-proxy-agent": "^7.0.
|
|
123
|
+
"http-proxy-agent": "^7.0.2",
|
|
124
|
+
"https-proxy-agent": "^7.0.4",
|
|
112
125
|
"kill-port": "^2.0.1",
|
|
113
126
|
"ora": "5",
|
|
114
127
|
"picocolors": "^1.0.0",
|
|
115
|
-
"tsx": "^4.7.
|
|
116
|
-
"unplugin": "^1.
|
|
128
|
+
"tsx": "^4.7.1",
|
|
129
|
+
"unplugin": "^1.7.1"
|
|
117
130
|
},
|
|
118
131
|
"devDependencies": {
|
|
119
|
-
"@antfu/eslint-config": "^0.40.
|
|
120
|
-
"@nuxt/kit": "^3.
|
|
121
|
-
"@nuxt/schema": "^3.
|
|
132
|
+
"@antfu/eslint-config": "^0.40.3",
|
|
133
|
+
"@nuxt/kit": "^3.10.2",
|
|
134
|
+
"@nuxt/schema": "^3.10.2",
|
|
135
|
+
"@rsbuild/core": "^0.4.3",
|
|
136
|
+
"@rspack/core": "^0.5.4",
|
|
122
137
|
"@types/kill-port": "^2.0.3",
|
|
123
|
-
"@types/node": "^20.
|
|
138
|
+
"@types/node": "^20.11.19",
|
|
124
139
|
"@vue/cli": "^5.0.8",
|
|
125
|
-
"bumpp": "^9.
|
|
140
|
+
"bumpp": "^9.3.0",
|
|
126
141
|
"chalk": "^5.3.0",
|
|
127
|
-
"eslint": "^8.
|
|
128
|
-
"fast-glob": "^3.3.
|
|
129
|
-
"nodemon": "^3.0.
|
|
130
|
-
"rimraf": "^5.0.
|
|
131
|
-
"rollup": "^3.
|
|
132
|
-
"tsup": "^7.
|
|
133
|
-
"typescript": "^5.
|
|
134
|
-
"vite": "^4.
|
|
135
|
-
"vitest": "^0.34.
|
|
136
|
-
"webpack": "^5.
|
|
142
|
+
"eslint": "^8.56.0",
|
|
143
|
+
"fast-glob": "^3.3.2",
|
|
144
|
+
"nodemon": "^3.0.3",
|
|
145
|
+
"rimraf": "^5.0.5",
|
|
146
|
+
"rollup": "^3.29.4",
|
|
147
|
+
"tsup": "^7.3.0",
|
|
148
|
+
"typescript": "^5.3.3",
|
|
149
|
+
"vite": "^4.5.2",
|
|
150
|
+
"vitest": "^0.34.6",
|
|
151
|
+
"webpack": "^5.90.3"
|
|
137
152
|
},
|
|
138
153
|
"scripts": {
|
|
139
154
|
"postinstall": "tsx scripts/postinstall.ts",
|
|
@@ -142,6 +157,7 @@
|
|
|
142
157
|
"build:fix": "tsx scripts/postbuild.ts",
|
|
143
158
|
"lint": "eslint .",
|
|
144
159
|
"play": "npm -C examples/vite run dev",
|
|
160
|
+
"play:rsbuild": "npm -C examples/rsbuild run dev",
|
|
145
161
|
"play:nuxt": "npm -C examples/nuxt run dev",
|
|
146
162
|
"play:vuecli": "npm -C examples/vuecli run serve",
|
|
147
163
|
"play:vuecli4": "npm -C examples/vuecli4 run serve",
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ let config: ResolvedConfig
|
|
|
11
11
|
|
|
12
12
|
let caddy: CaddyInstant
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const cwd = process.cwd()
|
|
15
15
|
|
|
16
16
|
export const vitePrintUrls = once((
|
|
17
17
|
options: Options,
|
|
@@ -102,7 +102,7 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
102
102
|
port: 8080,
|
|
103
103
|
...compiler.options.devServer,
|
|
104
104
|
// @ts-expect-error vuecli
|
|
105
|
-
...process.VUE_CLI_SERVICE
|
|
105
|
+
...(process.VUE_CLI_SERVICE?.projectOptions.devServer),
|
|
106
106
|
}
|
|
107
107
|
const source = `${devServer.host}:${devServer.port}`
|
|
108
108
|
|
|
@@ -137,6 +137,52 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
|
|
|
137
137
|
throw e
|
|
138
138
|
})
|
|
139
139
|
},
|
|
140
|
+
async rspack(compiler) {
|
|
141
|
+
if (process.env.NODE_ENV !== 'development')
|
|
142
|
+
return
|
|
143
|
+
|
|
144
|
+
if (!isAdmin()) {
|
|
145
|
+
consola.warn('please run as administrator')
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const {
|
|
150
|
+
enable = true,
|
|
151
|
+
target = '',
|
|
152
|
+
} = options
|
|
153
|
+
if (!enable)
|
|
154
|
+
return
|
|
155
|
+
if (!target) {
|
|
156
|
+
consola.fail('please provide target')
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const devServer = {
|
|
161
|
+
host: 'localhost',
|
|
162
|
+
port: 8080,
|
|
163
|
+
...compiler.options.devServer,
|
|
164
|
+
...(await (await import('@rsbuild/core'))?.loadConfig({
|
|
165
|
+
cwd,
|
|
166
|
+
}))?.content?.server,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const source = `${devServer.host}:${devServer.port}`
|
|
170
|
+
|
|
171
|
+
if (caddy)
|
|
172
|
+
return
|
|
173
|
+
|
|
174
|
+
caddy = new CaddyInstant()
|
|
175
|
+
|
|
176
|
+
caddy.run(source, target, {
|
|
177
|
+
...options,
|
|
178
|
+
}).then(() => {
|
|
179
|
+
const colorUrl = (url: string) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`))
|
|
180
|
+
|
|
181
|
+
consola.success(` ${c.green('➜')} ${c.bold('run caddy reverse proxy success')}: ${colorUrl(`${options.https ? 'https' : 'http'}://${target}`)}`)
|
|
182
|
+
}).catch((e) => {
|
|
183
|
+
throw e
|
|
184
|
+
})
|
|
185
|
+
},
|
|
140
186
|
})
|
|
141
187
|
|
|
142
188
|
export const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)
|