unplugin-https-reverse-proxy 0.0.18 → 0.0.20

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 CHANGED
@@ -16,10 +16,14 @@ UHRP_AUTO_INSTALL_CADDY=true npm i unplugin-https-reverse-proxy --save-dev
16
16
 
17
17
  ```ts
18
18
  interface Options {
19
- enable?: boolean // <- default: true
20
- target: string // <- https target hostname
21
- showCaddyLog?: boolean // <- default: false
22
- https?: boolean // <- default: false
19
+ /** default: true */
20
+ enable?: boolean
21
+ /** target hostname */
22
+ target: string
23
+ /** default: false */
24
+ showCaddyLog?: boolean
25
+ /** default: false */
26
+ https?: boolean
23
27
  }
24
28
  ```
25
29
 
@@ -44,24 +48,40 @@ Example: [`playground/`](./playground/)
44
48
  <details>
45
49
  <summary>Webpack</summary><br>
46
50
 
47
- ```ts
51
+ ```js
48
52
  // webpack.config.js
53
+
54
+ /** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
55
+ const reverseProxyOptions = {
56
+ enable: false,
57
+ target: 'xxx',
58
+ https: false,
59
+ }
60
+
49
61
  module.exports = {
50
62
  /* ... */
51
63
  devServer: {
52
64
  client: {
53
65
  // ↓ for HMR
54
66
  webSocketURL: {
55
- // protocol: 'wss', // <- if you set options.https to `true`
56
- // port: 443, // <- if you set options.https to `true`
57
- hostname: 'xxx', // <- target hostname
58
- },
67
+ ...(reverseProxyOptions.enable
68
+ ? {
69
+ hostname: reverseProxyOptions.target,
70
+ }
71
+ : {}),
72
+ ...(reverseProxyOptions.enable && reverseProxyOptions.https
73
+ ? {
74
+ protocol: 'wss',
75
+ port: 443,
76
+ }
77
+ : {})
78
+ }
59
79
  },
60
80
  setupExitSignals: true,
61
81
  allowedHosts: 'all',
62
82
  },
63
83
  plugins: [
64
- require('unplugin-https-reverse-proxy/webpack')({ /* options */ })
84
+ require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions)
65
85
  ]
66
86
  }
67
87
  ```
@@ -71,7 +91,7 @@ module.exports = {
71
91
  <details>
72
92
  <summary>Nuxt</summary><br>
73
93
 
74
- ```ts
94
+ ```js
75
95
  // nuxt.config.js
76
96
  export default defineNuxtConfig({
77
97
  modules: [
@@ -87,24 +107,40 @@ export default defineNuxtConfig({
87
107
  <details>
88
108
  <summary>Vue CLI</summary><br>
89
109
 
90
- ```ts
110
+ ```js
91
111
  // vue.config.js
112
+
113
+ /** @type {Parameters<import('unplugin-https-reverse-proxy/webpack')['default']>[0]} */
114
+ const reverseProxyOptions = {
115
+ enable: false,
116
+ target: 'xxx',
117
+ https: false,
118
+ }
119
+
92
120
  module.exports = {
93
121
  devServer: {
94
122
  client: {
95
123
  // ↓ for HMR
96
124
  webSocketURL: {
97
- // protocol: 'wss', // <- if you set options.https to `true`
98
- // port: 443, // <- if you set options.https to `true`
99
- port: 443,
100
- },
125
+ ...(reverseProxyOptions.enable
126
+ ? {
127
+ hostname: reverseProxyOptions.target,
128
+ }
129
+ : {}),
130
+ ...(reverseProxyOptions.enable && reverseProxyOptions.https
131
+ ? {
132
+ protocol: 'wss',
133
+ port: 443,
134
+ }
135
+ : {})
136
+ }
101
137
  },
102
138
  setupExitSignals: true,
103
139
  allowedHosts: 'all',
104
140
  },
105
141
  configureWebpack: {
106
142
  plugins: [
107
- require('unplugin-https-reverse-proxy/webpack')({ /* options */ }),
143
+ require('unplugin-https-reverse-proxy/webpack')(reverseProxyOptions),
108
144
  ],
109
145
  },
110
146
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-KYPQLMHO.js";
4
4
 
5
5
  // src/vite.ts
6
6
  import { createVitePlugin } from "unplugin";
@@ -6,6 +6,7 @@ import {
6
6
 
7
7
  // src/index.ts
8
8
  import process3 from "process";
9
+ import { chmodSync as chmodSync2 } from "fs";
9
10
  import { createUnplugin } from "unplugin";
10
11
  import c from "picocolors";
11
12
 
@@ -390,11 +391,11 @@ function registerExit(clear) {
390
391
  });
391
392
  process3.once("SIGINT", async () => {
392
393
  await clear();
393
- process3.emit("SIGINT");
394
+ process3.exit(0);
394
395
  });
395
396
  process3.once("SIGTERM", async () => {
396
397
  await clear();
397
- process3.emit("SIGTERM");
398
+ process3.exit(0);
398
399
  });
399
400
  }
400
401
  var unpluginFactory = (options) => ({
@@ -436,6 +437,9 @@ var unpluginFactory = (options) => ({
436
437
  server.printUrls = () => {
437
438
  var _a;
438
439
  _printUrls();
440
+ const pwd = process3.cwd();
441
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
442
+ chmodSync2(vireCacheDir, 511);
439
443
  let source = `localhost:${config.server.port}`;
440
444
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
441
445
  if (url) {
@@ -463,6 +467,8 @@ var unpluginFactory = (options) => ({
463
467
  }
464
468
  },
465
469
  webpack(compiler) {
470
+ if (process3.env.NODE_ENV !== "development")
471
+ return;
466
472
  const {
467
473
  enable = true,
468
474
  target = ""
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-KYPQLMHO.js";
4
4
 
5
5
  // src/webpack.ts
6
6
  import { createWebpackPlugin } from "unplugin";
package/dist/esbuild.cjs CHANGED
@@ -51,6 +51,7 @@ var import_unplugin2 = require("unplugin");
51
51
 
52
52
  // src/index.ts
53
53
  var import_node_process3 = __toESM(require("process"), 1);
54
+ var import_node_fs2 = require("fs");
54
55
  var import_unplugin = require("unplugin");
55
56
  var import_picocolors = __toESM(require("picocolors"), 1);
56
57
 
@@ -450,11 +451,11 @@ function registerExit(clear) {
450
451
  });
451
452
  import_node_process3.default.once("SIGINT", async () => {
452
453
  await clear();
453
- import_node_process3.default.emit("SIGINT");
454
+ import_node_process3.default.exit(0);
454
455
  });
455
456
  import_node_process3.default.once("SIGTERM", async () => {
456
457
  await clear();
457
- import_node_process3.default.emit("SIGTERM");
458
+ import_node_process3.default.exit(0);
458
459
  });
459
460
  }
460
461
  var unpluginFactory = (options) => ({
@@ -496,6 +497,9 @@ var unpluginFactory = (options) => ({
496
497
  server.printUrls = () => {
497
498
  var _a;
498
499
  _printUrls();
500
+ const pwd = import_node_process3.default.cwd();
501
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
502
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
499
503
  let source = `localhost:${config.server.port}`;
500
504
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
501
505
  if (url) {
@@ -523,6 +527,8 @@ var unpluginFactory = (options) => ({
523
527
  }
524
528
  },
525
529
  webpack(compiler) {
530
+ if (import_node_process3.default.env.NODE_ENV !== "development")
531
+ return;
526
532
  const {
527
533
  enable = true,
528
534
  target = ""
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-KYPQLMHO.js";
4
4
  import "./chunk-CQC5SSJR.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/index.cjs CHANGED
@@ -50,6 +50,7 @@ __export(src_exports, {
50
50
  });
51
51
  module.exports = __toCommonJS(src_exports);
52
52
  var import_node_process3 = __toESM(require("process"), 1);
53
+ var import_node_fs2 = require("fs");
53
54
  var import_unplugin = require("unplugin");
54
55
  var import_picocolors = __toESM(require("picocolors"), 1);
55
56
 
@@ -449,11 +450,11 @@ function registerExit(clear) {
449
450
  });
450
451
  import_node_process3.default.once("SIGINT", async () => {
451
452
  await clear();
452
- import_node_process3.default.emit("SIGINT");
453
+ import_node_process3.default.exit(0);
453
454
  });
454
455
  import_node_process3.default.once("SIGTERM", async () => {
455
456
  await clear();
456
- import_node_process3.default.emit("SIGTERM");
457
+ import_node_process3.default.exit(0);
457
458
  });
458
459
  }
459
460
  var unpluginFactory = (options) => ({
@@ -495,6 +496,9 @@ var unpluginFactory = (options) => ({
495
496
  server.printUrls = () => {
496
497
  var _a;
497
498
  _printUrls();
499
+ const pwd = import_node_process3.default.cwd();
500
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
501
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
498
502
  let source = `localhost:${config.server.port}`;
499
503
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
500
504
  if (url) {
@@ -522,6 +526,8 @@ var unpluginFactory = (options) => ({
522
526
  }
523
527
  },
524
528
  webpack(compiler) {
529
+ if (import_node_process3.default.env.NODE_ENV !== "development")
530
+ return;
525
531
  const {
526
532
  enable = true,
527
533
  target = ""
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  src_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-HXDI3VOY.js";
5
+ } from "./chunk-KYPQLMHO.js";
6
6
  import "./chunk-CQC5SSJR.js";
7
7
  export {
8
8
  src_default as default,
package/dist/nuxt.cjs CHANGED
@@ -54,6 +54,7 @@ var import_unplugin2 = require("unplugin");
54
54
 
55
55
  // src/index.ts
56
56
  var import_node_process3 = __toESM(require("process"), 1);
57
+ var import_node_fs2 = require("fs");
57
58
  var import_unplugin = require("unplugin");
58
59
  var import_picocolors = __toESM(require("picocolors"), 1);
59
60
 
@@ -453,11 +454,11 @@ function registerExit(clear) {
453
454
  });
454
455
  import_node_process3.default.once("SIGINT", async () => {
455
456
  await clear();
456
- import_node_process3.default.emit("SIGINT");
457
+ import_node_process3.default.exit(0);
457
458
  });
458
459
  import_node_process3.default.once("SIGTERM", async () => {
459
460
  await clear();
460
- import_node_process3.default.emit("SIGTERM");
461
+ import_node_process3.default.exit(0);
461
462
  });
462
463
  }
463
464
  var unpluginFactory = (options) => ({
@@ -499,6 +500,9 @@ var unpluginFactory = (options) => ({
499
500
  server.printUrls = () => {
500
501
  var _a;
501
502
  _printUrls();
503
+ const pwd = import_node_process3.default.cwd();
504
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
505
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
502
506
  let source = `localhost:${config.server.port}`;
503
507
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
504
508
  if (url) {
@@ -526,6 +530,8 @@ var unpluginFactory = (options) => ({
526
530
  }
527
531
  },
528
532
  webpack(compiler) {
533
+ if (import_node_process3.default.env.NODE_ENV !== "development")
534
+ return;
529
535
  const {
530
536
  enable = true,
531
537
  target = ""
package/dist/nuxt.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-D3S54OXA.js";
3
+ } from "./chunk-CVO5VP4I.js";
4
4
  import {
5
5
  webpack_default
6
- } from "./chunk-6MDRTXCZ.js";
7
- import "./chunk-HXDI3VOY.js";
6
+ } from "./chunk-VXVYW4ZE.js";
7
+ import "./chunk-KYPQLMHO.js";
8
8
  import "./chunk-CQC5SSJR.js";
9
9
 
10
10
  // src/nuxt.ts
package/dist/rollup.cjs CHANGED
@@ -51,6 +51,7 @@ var import_unplugin2 = require("unplugin");
51
51
 
52
52
  // src/index.ts
53
53
  var import_node_process3 = __toESM(require("process"), 1);
54
+ var import_node_fs2 = require("fs");
54
55
  var import_unplugin = require("unplugin");
55
56
  var import_picocolors = __toESM(require("picocolors"), 1);
56
57
 
@@ -450,11 +451,11 @@ function registerExit(clear) {
450
451
  });
451
452
  import_node_process3.default.once("SIGINT", async () => {
452
453
  await clear();
453
- import_node_process3.default.emit("SIGINT");
454
+ import_node_process3.default.exit(0);
454
455
  });
455
456
  import_node_process3.default.once("SIGTERM", async () => {
456
457
  await clear();
457
- import_node_process3.default.emit("SIGTERM");
458
+ import_node_process3.default.exit(0);
458
459
  });
459
460
  }
460
461
  var unpluginFactory = (options) => ({
@@ -496,6 +497,9 @@ var unpluginFactory = (options) => ({
496
497
  server.printUrls = () => {
497
498
  var _a;
498
499
  _printUrls();
500
+ const pwd = import_node_process3.default.cwd();
501
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
502
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
499
503
  let source = `localhost:${config.server.port}`;
500
504
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
501
505
  if (url) {
@@ -523,6 +527,8 @@ var unpluginFactory = (options) => ({
523
527
  }
524
528
  },
525
529
  webpack(compiler) {
530
+ if (import_node_process3.default.env.NODE_ENV !== "development")
531
+ return;
526
532
  const {
527
533
  enable = true,
528
534
  target = ""
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-KYPQLMHO.js";
4
4
  import "./chunk-CQC5SSJR.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/vite.cjs CHANGED
@@ -51,6 +51,7 @@ var import_unplugin2 = require("unplugin");
51
51
 
52
52
  // src/index.ts
53
53
  var import_node_process3 = __toESM(require("process"), 1);
54
+ var import_node_fs2 = require("fs");
54
55
  var import_unplugin = require("unplugin");
55
56
  var import_picocolors = __toESM(require("picocolors"), 1);
56
57
 
@@ -450,11 +451,11 @@ function registerExit(clear) {
450
451
  });
451
452
  import_node_process3.default.once("SIGINT", async () => {
452
453
  await clear();
453
- import_node_process3.default.emit("SIGINT");
454
+ import_node_process3.default.exit(0);
454
455
  });
455
456
  import_node_process3.default.once("SIGTERM", async () => {
456
457
  await clear();
457
- import_node_process3.default.emit("SIGTERM");
458
+ import_node_process3.default.exit(0);
458
459
  });
459
460
  }
460
461
  var unpluginFactory = (options) => ({
@@ -496,6 +497,9 @@ var unpluginFactory = (options) => ({
496
497
  server.printUrls = () => {
497
498
  var _a;
498
499
  _printUrls();
500
+ const pwd = import_node_process3.default.cwd();
501
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
502
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
499
503
  let source = `localhost:${config.server.port}`;
500
504
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
501
505
  if (url) {
@@ -523,6 +527,8 @@ var unpluginFactory = (options) => ({
523
527
  }
524
528
  },
525
529
  webpack(compiler) {
530
+ if (import_node_process3.default.env.NODE_ENV !== "development")
531
+ return;
526
532
  const {
527
533
  enable = true,
528
534
  target = ""
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-D3S54OXA.js";
4
- import "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-CVO5VP4I.js";
4
+ import "./chunk-KYPQLMHO.js";
5
5
  import "./chunk-CQC5SSJR.js";
6
6
  export {
7
7
  vite_default as default
package/dist/webpack.cjs CHANGED
@@ -51,6 +51,7 @@ var import_unplugin2 = require("unplugin");
51
51
 
52
52
  // src/index.ts
53
53
  var import_node_process3 = __toESM(require("process"), 1);
54
+ var import_node_fs2 = require("fs");
54
55
  var import_unplugin = require("unplugin");
55
56
  var import_picocolors = __toESM(require("picocolors"), 1);
56
57
 
@@ -450,11 +451,11 @@ function registerExit(clear) {
450
451
  });
451
452
  import_node_process3.default.once("SIGINT", async () => {
452
453
  await clear();
453
- import_node_process3.default.emit("SIGINT");
454
+ import_node_process3.default.exit(0);
454
455
  });
455
456
  import_node_process3.default.once("SIGTERM", async () => {
456
457
  await clear();
457
- import_node_process3.default.emit("SIGTERM");
458
+ import_node_process3.default.exit(0);
458
459
  });
459
460
  }
460
461
  var unpluginFactory = (options) => ({
@@ -496,6 +497,9 @@ var unpluginFactory = (options) => ({
496
497
  server.printUrls = () => {
497
498
  var _a;
498
499
  _printUrls();
500
+ const pwd = import_node_process3.default.cwd();
501
+ const vireCacheDir = `${pwd}/node_modules/.vite`;
502
+ (0, import_node_fs2.chmodSync)(vireCacheDir, 511);
499
503
  let source = `localhost:${config.server.port}`;
500
504
  const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
501
505
  if (url) {
@@ -523,6 +527,8 @@ var unpluginFactory = (options) => ({
523
527
  }
524
528
  },
525
529
  webpack(compiler) {
530
+ if (import_node_process3.default.env.NODE_ENV !== "development")
531
+ return;
526
532
  const {
527
533
  enable = true,
528
534
  target = ""
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  webpack_default
3
- } from "./chunk-6MDRTXCZ.js";
4
- import "./chunk-HXDI3VOY.js";
3
+ } from "./chunk-VXVYW4ZE.js";
4
+ import "./chunk-KYPQLMHO.js";
5
5
  import "./chunk-CQC5SSJR.js";
6
6
  export {
7
7
  webpack_default as default
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-https-reverse-proxy",
3
3
  "type": "module",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "packageManager": "pnpm@8.6.12",
6
6
  "description": "",
7
7
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import process from 'node:process'
2
+ import { chmodSync } from 'node:fs'
2
3
  import type { UnpluginFactory } from 'unplugin'
3
4
  import { createUnplugin } from 'unplugin'
4
5
  import type { ResolvedConfig, ViteDevServer } from 'vite'
@@ -37,12 +38,12 @@ function registerExit(clear: (() => Promise<any>) | (() => any)) {
37
38
 
38
39
  process.once('SIGINT', async () => {
39
40
  await clear()
40
- process.emit('SIGINT')
41
+ process.exit(0)
41
42
  })
42
43
 
43
44
  process.once('SIGTERM', async () => {
44
45
  await clear()
45
- process.emit('SIGTERM')
46
+ process.exit(0)
46
47
  })
47
48
  }
48
49
 
@@ -87,6 +88,12 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
87
88
  const _printUrls = server.printUrls
88
89
  server.printUrls = () => {
89
90
  _printUrls()
91
+
92
+ // fix `Error: EPERM: operation not permitted`
93
+ const pwd = process.cwd()
94
+ const vireCacheDir = `${pwd}/node_modules/.vite`
95
+ chmodSync(vireCacheDir, 0o777)
96
+
90
97
  let source = `localhost:${config.server.port}`
91
98
  const url = server.resolvedUrls?.local[0]
92
99
  if (url) {
@@ -116,6 +123,9 @@ export const unpluginFactory: UnpluginFactory<Options> = options => ({
116
123
  },
117
124
  },
118
125
  webpack(compiler) {
126
+ if (process.env.NODE_ENV !== 'development')
127
+ return
128
+
119
129
  const {
120
130
  enable = true,
121
131
  target = '',