@vtj/local 0.13.36 → 0.13.38

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/dist/index.cjs CHANGED
@@ -1982,6 +1982,32 @@ const umdBuildPlugin = function(options) {
1982
1982
  }
1983
1983
  };
1984
1984
  };
1985
+ const pathRewritePlugin = (options) => {
1986
+ const { pathRewrite = [] } = options;
1987
+ return {
1988
+ name: "web-path-rewrite",
1989
+ configureServer(server) {
1990
+ server.middlewares.use((req, _res, next) => {
1991
+ for (const item of pathRewrite) {
1992
+ if (req.url?.startsWith(item)) {
1993
+ req.url = item;
1994
+ }
1995
+ }
1996
+ next();
1997
+ });
1998
+ },
1999
+ configurePreviewServer(server) {
2000
+ server.middlewares.use((req, _res, next) => {
2001
+ for (const item of pathRewrite) {
2002
+ if (req.url?.startsWith(item)) {
2003
+ req.url = item;
2004
+ }
2005
+ }
2006
+ next();
2007
+ });
2008
+ }
2009
+ };
2010
+ };
1985
2011
  function parsePresetPlugins(options) {
1986
2012
  const {
1987
2013
  presetPlugins = [],
@@ -2160,6 +2186,9 @@ function createDevTools(options = {}) {
2160
2186
  if (opts.enhance) {
2161
2187
  plugins.push(umdBuildPlugin(opts));
2162
2188
  }
2189
+ if (opts.pathRewrite) {
2190
+ plugins.push(pathRewritePlugin(opts));
2191
+ }
2163
2192
  return plugins;
2164
2193
  }
2165
2194
 
package/dist/index.d.cts CHANGED
@@ -25,6 +25,7 @@ interface DevToolsOptions {
25
25
  enhance?: boolean | EnhanceOptions;
26
26
  devtools?: StaticPluginOption;
27
27
  copyDevtools?: boolean;
28
+ pathRewrite?: string[];
28
29
  }
29
30
  interface EnhanceOptions {
30
31
  entry?: string;
package/dist/index.d.mts CHANGED
@@ -25,6 +25,7 @@ interface DevToolsOptions {
25
25
  enhance?: boolean | EnhanceOptions;
26
26
  devtools?: StaticPluginOption;
27
27
  copyDevtools?: boolean;
28
+ pathRewrite?: string[];
28
29
  }
29
30
  interface EnhanceOptions {
30
31
  entry?: string;
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ interface DevToolsOptions {
25
25
  enhance?: boolean | EnhanceOptions;
26
26
  devtools?: StaticPluginOption;
27
27
  copyDevtools?: boolean;
28
+ pathRewrite?: string[];
28
29
  }
29
30
  interface EnhanceOptions {
30
31
  entry?: string;
package/dist/index.mjs CHANGED
@@ -1975,6 +1975,32 @@ const umdBuildPlugin = function(options) {
1975
1975
  }
1976
1976
  };
1977
1977
  };
1978
+ const pathRewritePlugin = (options) => {
1979
+ const { pathRewrite = [] } = options;
1980
+ return {
1981
+ name: "web-path-rewrite",
1982
+ configureServer(server) {
1983
+ server.middlewares.use((req, _res, next) => {
1984
+ for (const item of pathRewrite) {
1985
+ if (req.url?.startsWith(item)) {
1986
+ req.url = item;
1987
+ }
1988
+ }
1989
+ next();
1990
+ });
1991
+ },
1992
+ configurePreviewServer(server) {
1993
+ server.middlewares.use((req, _res, next) => {
1994
+ for (const item of pathRewrite) {
1995
+ if (req.url?.startsWith(item)) {
1996
+ req.url = item;
1997
+ }
1998
+ }
1999
+ next();
2000
+ });
2001
+ }
2002
+ };
2003
+ };
1978
2004
  function parsePresetPlugins(options) {
1979
2005
  const {
1980
2006
  presetPlugins = [],
@@ -2153,6 +2179,9 @@ function createDevTools(options = {}) {
2153
2179
  if (opts.enhance) {
2154
2180
  plugins.push(umdBuildPlugin(opts));
2155
2181
  }
2182
+ if (opts.pathRewrite) {
2183
+ plugins.push(pathRewritePlugin(opts));
2184
+ }
2156
2185
  return plugins;
2157
2186
  }
2158
2187
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/local",
3
3
  "private": false,
4
- "version": "0.13.36",
4
+ "version": "0.13.38",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -22,16 +22,16 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "formidable": "~3.5.1",
25
- "@vtj/coder": "~0.13.36",
26
- "@vtj/core": "~0.13.36",
25
+ "@vtj/coder": "~0.13.38",
26
+ "@vtj/core": "~0.13.38",
27
27
  "@vtj/node": "~0.12.6",
28
- "@vtj/parser": "~0.13.36"
28
+ "@vtj/parser": "~0.13.38"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/formidable": "~3.4.5",
32
32
  "unbuild": "~2.0.0",
33
33
  "vite": "~6.3.0",
34
- "@vtj/cli": "~0.12.16"
34
+ "@vtj/cli": "~0.12.17"
35
35
  },
36
36
  "exports": {
37
37
  ".": {