vite.config.js 1.8 KB

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