vite.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { defineConfig } from "vite"
  2. import react from "@vitejs/plugin-react"
  3. import svgr from "vite-plugin-svgr"
  4. import { name } from "./package.json"
  5. const genBaseUrl = (mode) => {
  6. if (mode !== "development") {
  7. if (mode == "test") {
  8. return `/${name}-test/`
  9. }
  10. return `/${name}/`
  11. }
  12. return "/"
  13. }
  14. export default defineConfig(({ mode }) => {
  15. return {
  16. resolve: {
  17. alias: {
  18. "@": "/src",
  19. "@/packages/stt-sdk-core": "/packages/stt-sdk-core/src",
  20. },
  21. },
  22. base: genBaseUrl(mode),
  23. build: {
  24. // cssCodeSplit: false,
  25. // target: "es2015",
  26. },
  27. server: {
  28. host: "0.0.0.0",
  29. allowedHosts: true,
  30. port: 8080,
  31. watch: {
  32. // usePolling: true
  33. },
  34. },
  35. plugins: [
  36. react(),
  37. svgr({
  38. svgrOptions: {
  39. // icon: true,
  40. // typescript: true,
  41. },
  42. }),
  43. ],
  44. css: {
  45. preprocessorOptions: {
  46. scss: {
  47. api: "modern",
  48. },
  49. },
  50. modules: {
  51. // hashPrefix: 'hash',
  52. // generateScopedName: "[name]__[local]__[hash:base64:2]",
  53. // globalModulePaths: [
  54. // /.*\\.global\\..*/
  55. // ]
  56. },
  57. postcss: {
  58. plugins: [],
  59. },
  60. },
  61. }
  62. })