vite.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
  33. },
  34. css: {
  35. preprocessorOptions: {
  36. less: {
  37. javascriptEnabled: true,
  38. modifyVars: {
  39. // "white": "#3C3F41",
  40. // "primary-color": "#3C3F41",
  41. },
  42. }
  43. },
  44. modules: {
  45. localsConvention: "camelCaseOnly"
  46. }
  47. },
  48. clearScreen: true,
  49. server: {
  50. host: "0.0.0.0",
  51. port: 8000,
  52. proxy: {
  53. "/api/": {
  54. target: "http://127.0.0.1:18081",
  55. changeOrigin: true,
  56. // rewrite: path => path,
  57. },
  58. "/api/ws/": {
  59. target: "http://127.0.0.1:18081",
  60. changeOrigin: true,
  61. ws: true,
  62. },
  63. },
  64. force: true,
  65. },
  66. build: {
  67. target: "modules",
  68. polyfillDynamicImport: false,
  69. outDir: "dist",
  70. assetsDir: "assets",
  71. assetsInlineLimit: 4096,
  72. cssCodeSplit: true,
  73. rollupOptions: {
  74. external: [],
  75. plugins: [],
  76. output: {
  77. // name: name,
  78. // exports: 'named',
  79. // format: 'amd',
  80. sourcemap: true,
  81. },
  82. },
  83. },
  84. });