@nikoyo-spa/vite-config 1.3.8 → 1.3.10

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.
Files changed (2) hide show
  1. package/dist/index.mjs +22 -6
  2. package/package.json +8 -8
package/dist/index.mjs CHANGED
@@ -32,7 +32,6 @@ function defineConfig(userConfig = {}) {
32
32
  VITE_PROXY_HOST = "http://localhost:8080"
33
33
  } = env;
34
34
  const port = +VITE_DEV_PORT;
35
- const isBuild = command === "build";
36
35
  const pkgPath = path.resolve(process.cwd(), "package.json");
37
36
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
38
37
  const { name } = pkg;
@@ -154,10 +153,26 @@ function defineConfig(userConfig = {}) {
154
153
  ],
155
154
  build: {
156
155
  rollupOptions: {
157
- external: VITE_BUILD_EXTERNAL
156
+ external: VITE_BUILD_EXTERNAL,
157
+ output: {
158
+ // 最小化拆分包
159
+ manualChunks(id) {
160
+ if (id.includes("node_modules")) {
161
+ const pkgName = id.split("node_modules/")[1].split("/")[1];
162
+ return `vendor-${pkgName}`;
163
+ }
164
+ }
165
+ }
158
166
  },
159
167
  cssCodeSplit: true,
160
- esbuild: isBuild ? { drop: ["console", "debugger"] } : {}
168
+ minify: "terser",
169
+ terserOptions: {
170
+ compress: {
171
+ // 生产环境时移除console
172
+ drop_console: true,
173
+ drop_debugger: true
174
+ }
175
+ }
161
176
  },
162
177
  server: {
163
178
  hmr: true,
@@ -204,6 +219,7 @@ function renderAttrs(attrs) {
204
219
  return Object.entries(attrs).map(([k, v]) => `${k}="${v}"`).join(" ");
205
220
  }
206
221
  function createProxy(target, paths) {
222
+ const url = new URL(target);
207
223
  return Object.fromEntries(
208
224
  paths.map((path2) => [
209
225
  path2,
@@ -213,9 +229,9 @@ function createProxy(target, paths) {
213
229
  secure: false,
214
230
  configure: (proxy) => {
215
231
  proxy.on("proxyReq", (proxyReq) => {
216
- proxyReq.setHeader("Host", "192.168.1.36:8080");
217
- proxyReq.setHeader("Origin", "http://192.168.1.36:8080");
218
- proxyReq.setHeader("Referer", `http://192.168.1.36:8080${path2}`);
232
+ proxyReq.setHeader("Host", url.host);
233
+ proxyReq.setHeader("Origin", url.origin);
234
+ proxyReq.setHeader("Referer", `${url.origin}${path2}`);
219
235
  });
220
236
  }
221
237
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nikoyo-spa/vite-config",
3
3
  "type": "module",
4
- "version": "1.3.8",
4
+ "version": "1.3.10",
5
5
  "description": "Spa Vite Config",
6
6
  "author": "qianyongdong <https://github.com/qianyongdong>",
7
7
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "unplugin-icons": "^22.5.0",
44
44
  "unplugin-vue-components": "^30.0.0",
45
45
  "unplugin-vue-router": "^0.19.1",
46
- "vite": "^7.3.0",
46
+ "vite": "^7.3.1",
47
47
  "vite-plugin-compression2": "^2.4.0",
48
48
  "vite-plugin-inspect": "^11.3.3",
49
49
  "vite-plugin-single-spa": "^1.1.0",
@@ -53,12 +53,12 @@
53
53
  "vue": "^3.5.27",
54
54
  "vue-i18n": "^11.2.2",
55
55
  "vue-router": "^4.6.4",
56
- "@nikoyo-spa/components": "1.3.8",
57
- "@nikoyo-spa/core": "1.3.8",
58
- "@nikoyo-spa/icons": "1.3.8",
59
- "@nikoyo-spa/metadata": "1.3.8",
60
- "@nikoyo-spa/import-map-shared": "1.3.8",
61
- "@nikoyo-spa/resolvers": "1.3.8"
56
+ "@nikoyo-spa/components": "1.3.10",
57
+ "@nikoyo-spa/icons": "1.3.10",
58
+ "@nikoyo-spa/core": "1.3.10",
59
+ "@nikoyo-spa/resolvers": "1.3.10",
60
+ "@nikoyo-spa/metadata": "1.3.10",
61
+ "@nikoyo-spa/import-map-shared": "1.3.10"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "pnpm unbuild",