12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { defineConfig } from "vite";
- import react from "@vitejs/plugin-react";
- import path from "path";
- // https://vite.dev/config/
- export default defineConfig({
- plugins: [react()],
- css: {
- modules: {
- generateScopedName: "[name]__[local]___[hash:base64:5]", // 自定义类名生成规则
- },
- },
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "src"),
- },
- // mainFields: ['module', 'jsnext:main', 'jsnext', 'main'],
- },
- server: {
- host: true,
- port: 8080,
- open: true,
- cors: true,
- // vite 反向代理
- proxy: {
- "/api": {
- target: "http://192.168.1.112:19801",
- changeOrigin: false,
- rewrite: (path) => path.replace(/^\/api/, ""),
- },
- },
- },
- build: {
- // 静态资源打包到dist下的不同目录
- rollupOptions: {
- output: {
- chunkFileNames: 'static/js/[name]-[hash].js',
- entryFileNames: 'static/js/[name]-[hash].js',
- assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
- },
- }
- }
- });
|