vite.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import graphql from '@rollup/plugin-graphql';
  5. import { viteRequire } from 'vite-require'
  6. import svgLoader from 'vite-svg-loader'
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. plugins: [vue({
  10. template: {
  11. compilerOptions: {
  12. whitespace: 'preserve'
  13. }
  14. }
  15. }), graphql(), viteRequire(), svgLoader({defaultImport: 'raw'})],
  16. resolve: {
  17. alias: {
  18. '@': fileURLToPath(new URL('./src', import.meta.url)),
  19. '@stores': fileURLToPath(new URL('./src/stores', import.meta.url)),
  20. '@components': fileURLToPath(new URL('./src/components', import.meta.url)),
  21. '@views': fileURLToPath(new URL('./src/views', import.meta.url)),
  22. '@api': fileURLToPath(new URL('./src/api', import.meta.url)),
  23. // '@icons': fileURLToPath(new URL('./node_modules/vue-material-design-icons', import.meta.url)),
  24. '@node_modules': fileURLToPath(new URL('./node_modules', import.meta.url))
  25. }
  26. },
  27. css: {
  28. preprocessorOptions: {
  29. scss: {
  30. // example : additionalData: `@import "./src/design/styles/variables";`
  31. // dont need include file extend .scss
  32. additionalData: `@import "./src/assets/colors.scss";@import "./src/assets/common.scss";`
  33. },
  34. },
  35. },
  36. build: {
  37. rollupOptions: {
  38. // https://rollupjs.org/configuration-options/
  39. },
  40. },
  41. // https://github.com/vitejs/vite/discussions/7920
  42. esbuild: {
  43. drop: ['console', 'debugger'],
  44. },
  45. })