vite.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { defineConfig } from "vite";
  2. import legacy from "@vitejs/plugin-legacy";
  3. import vitePluginImp from "vite-plugin-imp";
  4. const path = require("path");
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. // root: "./public/",
  8. base: "./",
  9. define: {
  10. // isProdEnv: NODE_ENV === "production",
  11. // apiGlobalPrefix: JSON.stringify(""),
  12. // "process.env": "{}",
  13. },
  14. plugins: [
  15. legacy({
  16. targets: ["defaults", "not IE 11"],
  17. }),
  18. vitePluginImp({
  19. libList: [
  20. // { libName: "antd", style: name => `antd/es/${name}/style/index.css` },
  21. ],
  22. }),
  23. ],
  24. publicDir: "public",
  25. resolve: {
  26. alias: {
  27. "~": path.resolve(__dirname, "./"),
  28. "@": path.resolve(__dirname, "./src/"),
  29. },
  30. },
  31. css: {
  32. preprocessorOptions: {
  33. less: {
  34. javascriptEnabled: true,
  35. modifyVars: {
  36. // "white": "#3C3F41",
  37. // "primary-color": "#3C3F41",
  38. },
  39. }
  40. },
  41. modules: {
  42. localsConvention: "camelCaseOnly"
  43. }
  44. },
  45. clearScreen: true,
  46. server: {
  47. host: "0.0.0.0",
  48. port: 8000,
  49. proxy: {
  50. "/api/": {
  51. target: "http://127.0.0.1:18081",
  52. changeOrigin: true,
  53. // rewrite: path => path,
  54. },
  55. "/api/ws/": {
  56. target: "http://127.0.0.1:18081",
  57. changeOrigin: true,
  58. ws: true,
  59. },
  60. },
  61. force: true,
  62. },
  63. build: {
  64. target: "modules",
  65. polyfillDynamicImport: false,
  66. outDir: "dist",
  67. assetsDir: "assets",
  68. assetsInlineLimit: 4096,
  69. cssCodeSplit: true,
  70. rollupOptions: {
  71. external: [],
  72. plugins: [
  73. ],
  74. output: {
  75. // name: name,
  76. // exports: 'named',
  77. // format: 'amd',
  78. sourcemap: true,
  79. },
  80. },
  81. },
  82. });