@xysfe/vite-plugin-dev-proxy 1.0.5 → 1.0.7

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
@@ -64,16 +64,30 @@ export default defineConfig({
64
64
  ```javascript
65
65
  // vue.config.js
66
66
  const { VueCliPluginDevProxy } = require("@xysfe/vite-plugin-dev-proxy");
67
-
68
- module.exports = VueCliPluginDevProxy({
69
- appHost: "example.com",
67
+ const staticPrefix = "/dev/static";
68
+ const devProxy = VueCliPluginDevProxy({
69
+ appHost: "beta-internal.cxmuc.com",
70
70
  https: true,
71
- entry: ["/js/chunk-vendors.js", "/js/app.js"],
72
- staticPrefix: "/dev/static",
71
+ staticPrefix: staticPrefix,
72
+ clearScriptCssPrefixes: ["//sslstatic.xiaoyusan.com/contract"],
73
73
  remotePrefixes: ["/static/component"],
74
- clearScriptCssPrefixes: "/static",
74
+ developmentAgentOccupancy: "",
75
+ // entry: dynamicEntry,
75
76
  debug: true,
76
77
  });
78
+
79
+ module.exports = {
80
+ outputDir: outputDir,
81
+ indexPath: indexPath,
82
+ publicPath: staticPrefix,
83
+ lintOnSave: lint,
84
+ runtimeCompiler: true,
85
+ productionSourceMap,
86
+ crossorigin: "anonymous",
87
+ devServer: {
88
+ proxy: devProxy.devServer.proxy,
89
+ },
90
+ };
77
91
  ```
78
92
 
79
93
  ## 📚 配置选项
package/dist/index.cjs CHANGED
@@ -123,7 +123,8 @@ function shouldUseLocal(url, normalizedStaticPrefix, remotePrefixes) {
123
123
  const pathname = url.split("?")[0];
124
124
  const isLocalResource = normalizedStaticPrefix && url.startsWith(normalizedStaticPrefix) || url.startsWith("/@") || url.startsWith("/src") || url.startsWith("/node_modules") || url.includes(".hot-update.") || url.startsWith("/sockjs-node") || // Vue CLI/Webpack 热更新 WebSocket (3.x)
125
125
  url.startsWith("/ws") || // Vue CLI/Webpack 热更新 WebSocket (4.x+/Vite)
126
- url === "/" || BYPASS_REGEX.test(pathname);
126
+ // url === "/" || // 根路径处理,默认也走远程吧,走本地不处理,默认都读本地的html vue-cli配置的 indexPath: indexPath,
127
+ BYPASS_REGEX.test(pathname);
127
128
  const isRemoteResource = matchesRemoteResource(url, remotePrefixes);
128
129
  return isLocalResource && !isRemoteResource;
129
130
  }
@@ -143,10 +144,7 @@ function handleRedirect(proxyRes, req, res, appHost, log2, startTime) {
143
144
  }
144
145
  function handleLibModeHtml(localIndexHtml, res, log2, logError, startTime) {
145
146
  try {
146
- const indexHtml = fs__default.readFileSync(
147
- path.resolve(__dirname, localIndexHtml),
148
- "utf-8"
149
- );
147
+ const indexHtml = fs__default.readFileSync(path.resolve(localIndexHtml), "utf-8");
150
148
  res.writeHead(200, {
151
149
  "Content-Type": "text/html; charset=utf-8"
152
150
  });
@@ -445,7 +443,11 @@ function createVueCliProxyConfig(options) {
445
443
  }
446
444
  function vueCliDevProxy(options = {}) {
447
445
  if (process.env.NODE_ENV !== "development") {
448
- return {};
446
+ return {
447
+ devServer: {
448
+ proxy: {}
449
+ }
450
+ };
449
451
  }
450
452
  const proxyConfig = createVueCliProxyConfig(options);
451
453
  return {
package/dist/index.mjs CHANGED
@@ -114,7 +114,8 @@ function shouldUseLocal(url, normalizedStaticPrefix, remotePrefixes) {
114
114
  const pathname = url.split("?")[0];
115
115
  const isLocalResource = normalizedStaticPrefix && url.startsWith(normalizedStaticPrefix) || url.startsWith("/@") || url.startsWith("/src") || url.startsWith("/node_modules") || url.includes(".hot-update.") || url.startsWith("/sockjs-node") || // Vue CLI/Webpack 热更新 WebSocket (3.x)
116
116
  url.startsWith("/ws") || // Vue CLI/Webpack 热更新 WebSocket (4.x+/Vite)
117
- url === "/" || BYPASS_REGEX.test(pathname);
117
+ // url === "/" || // 根路径处理,默认也走远程吧,走本地不处理,默认都读本地的html vue-cli配置的 indexPath: indexPath,
118
+ BYPASS_REGEX.test(pathname);
118
119
  const isRemoteResource = matchesRemoteResource(url, remotePrefixes);
119
120
  return isLocalResource && !isRemoteResource;
120
121
  }
@@ -134,10 +135,7 @@ function handleRedirect(proxyRes, req, res, appHost, log2, startTime) {
134
135
  }
135
136
  function handleLibModeHtml(localIndexHtml, res, log2, logError, startTime) {
136
137
  try {
137
- const indexHtml = fs.readFileSync(
138
- resolve(__dirname, localIndexHtml),
139
- "utf-8"
140
- );
138
+ const indexHtml = fs.readFileSync(resolve(localIndexHtml), "utf-8");
141
139
  res.writeHead(200, {
142
140
  "Content-Type": "text/html; charset=utf-8"
143
141
  });
@@ -436,7 +434,11 @@ function createVueCliProxyConfig(options) {
436
434
  }
437
435
  function vueCliDevProxy(options = {}) {
438
436
  if (process.env.NODE_ENV !== "development") {
439
- return {};
437
+ return {
438
+ devServer: {
439
+ proxy: {}
440
+ }
441
+ };
440
442
  }
441
443
  const proxyConfig = createVueCliProxyConfig(options);
442
444
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xysfe/vite-plugin-dev-proxy",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A Vite plugin for development environment proxy that automatically proxies remote server requests and handles HTML responses",
5
5
  "files": [
6
6
  "dist"