2023-04-03 21:31:59 +08:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import react from '@vitejs/plugin-react';
|
2023-04-01 12:58:49 -07:00
|
|
|
import path from 'path';
|
2023-04-07 07:27:05 -07:00
|
|
|
import type { Plugin } from "vite";
|
2023-04-01 12:58:49 -07:00
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
server: {
|
2023-04-03 21:31:59 +08:00
|
|
|
host: 'localhost',
|
2023-04-01 12:58:49 -07:00
|
|
|
port: 3090,
|
|
|
|
|
strictPort: false,
|
|
|
|
|
proxy: {
|
2023-04-03 21:31:59 +08:00
|
|
|
'/api': {
|
|
|
|
|
target: 'http://localhost:3080',
|
|
|
|
|
changeOrigin: true
|
|
|
|
|
},
|
|
|
|
|
'/auth': {
|
|
|
|
|
target: 'http://localhost:3080',
|
|
|
|
|
changeOrigin: true
|
2023-04-01 12:58:49 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-04-07 07:27:05 -07:00
|
|
|
plugins: [react(), sourcemapExclude({ excludeNodeModules: true }),],
|
2023-04-03 21:31:59 +08:00
|
|
|
publicDir: './public',
|
2023-04-01 12:58:49 -07:00
|
|
|
build: {
|
|
|
|
|
sourcemap: true,
|
2023-04-07 07:27:05 -07:00
|
|
|
outDir: './dist',
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: (id) => {
|
|
|
|
|
if (id.includes("node_modules")) {
|
|
|
|
|
return "vendor";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-04-01 12:58:49 -07:00
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2023-04-03 21:31:59 +08:00
|
|
|
'~': path.join(__dirname, 'src/')
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-01 12:58:49 -07:00
|
|
|
});
|
2023-04-07 07:27:05 -07:00
|
|
|
|
|
|
|
|
interface SourcemapExclude {
|
|
|
|
|
excludeNodeModules?: boolean;
|
|
|
|
|
}
|
|
|
|
|
export function sourcemapExclude(opts?: SourcemapExclude): Plugin {
|
|
|
|
|
return {
|
|
|
|
|
name: "sourcemap-exclude",
|
|
|
|
|
transform(code: string, id: string) {
|
|
|
|
|
if (opts?.excludeNodeModules && id.includes("node_modules")) {
|
|
|
|
|
return {
|
|
|
|
|
code,
|
|
|
|
|
// https://github.com/rollup/rollup/blob/master/docs/plugin-development/index.md#source-code-transformations
|
|
|
|
|
map: { mappings: "" },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|