|
1 | | -import {defineConfig, splitVendorChunkPlugin} from "vite"; |
| 1 | +import {defineConfig} from "vite"; |
2 | 2 | import vue from "@vitejs/plugin-vue"; |
3 | 3 |
|
4 | 4 | export default defineConfig({ |
5 | 5 | plugins: [ |
6 | 6 | vue(), |
7 | | - splitVendorChunkPlugin(), |
8 | 7 | ], |
9 | 8 | server: { |
10 | 9 | open: "/" |
11 | 10 | }, |
12 | | - base: "./", // Required for GitHub Pages |
13 | | - build: { |
14 | | - target: "es2020", |
15 | | - sourcemap: true, |
16 | | - rollupOptions: { |
17 | | - plugins: [ |
18 | | - sourceMapsPathChangerPlugin([ |
19 | | - // Use "../../" instead of "../" if resources are in "assets/" directory |
20 | | - ["../node_modules/", "node-modules:///"], |
21 | | - ["../vite/", "node-modules:///vite/"], |
22 | | - ["../src/", "source-maps:///"], |
23 | | - ["../", "source-maps:///"], |
24 | | - ]), |
25 | | - ], |
26 | | - output: { |
27 | | - entryFileNames: `[name].js`, // `[name].[hash].[format].js` |
28 | | - chunkFileNames: `[name].js`, |
29 | | - assetFileNames: `[name].[ext]`, |
30 | | - } |
31 | | - }, |
32 | | - minify: "terser", |
33 | | - terserOptions: { |
34 | | - mangle: { |
35 | | - keep_classnames: true, |
36 | | - keep_fnames: true, |
37 | | - } |
38 | | - } |
39 | | - } |
| 11 | + base: "./", |
40 | 12 | }); |
41 | | - |
42 | | -function sourceMapsPathChangerPlugin(pathsMapping = []) { |
43 | | - function changeSourceMapPaths(map) { |
44 | | - function _beautify(str) { |
45 | | - return pathsMapping.reduce((pre, [value, replacer]) => { |
46 | | - return pre.replace(value, replacer) |
47 | | - }, str); |
48 | | - } |
49 | | - for (let i = 0; i < map.sources.length; i++) { |
50 | | - map.sources[i] = _beautify(map.sources[i]); |
51 | | - } |
52 | | - return map; |
53 | | - } |
54 | | - return { |
55 | | - name: "source-maps-path-changer-plugin", |
56 | | - async generateBundle(options, bundle, isWrite) { |
57 | | - Object.keys(bundle).forEach(key => { |
58 | | - const map = bundle[key]?.map; |
59 | | - if (map) { |
60 | | - bundle[key].map = changeSourceMapPaths(map); |
61 | | - } |
62 | | - }); |
63 | | - } |
64 | | - } |
65 | | -} |
0 commit comments