vite.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { defineConfig } from 'vite';
  2. import { svelte } from '@sveltejs/vite-plugin-svelte';
  3. import UnoCSS from 'unocss/vite';
  4. import extractorSvelte from '@unocss/extractor-svelte';
  5. import svgSprite from 'rollup-plugin-stdf-icon';
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. plugins: [
  9. UnoCSS({
  10. extractors: [extractorSvelte()],
  11. }),
  12. svelte({
  13. onwarn(warning, defaultHandler) {
  14. const ignoredWarnings = [
  15. 'a11y-distracting-elements',
  16. 'a11y-no-static-element-interactions',
  17. 'a11y-click-events-have-key-events',
  18. 'a11y-no-noninteractive-element-interactions',
  19. ];
  20. const { code } = warning;
  21. // don't warn on <marquee> elements, cos they're cool
  22. if (ignoredWarnings.includes(code)) return;
  23. // handle all other warnings normally
  24. defaultHandler(warning);
  25. },
  26. }),
  27. // 一般来说,一个应用的所有 svg 都放在一个文件夹下,合并为一个 symbol 即可。
  28. // 如默认配置的 src/assets/icons 内,合并之后 symbol 会放置于 public/fonts/symbol.svg 下。
  29. // 此处只是为了演示不同文件夹下的图标如何合并为不同的 symbol。
  30. // Generally speaking, all of an application svg are placed in a folder and merged into one symbol.
  31. // As in the default configuration of src/assets/icons, the merged symbol will be placed under public/fonts/symbol.svg.
  32. // Here is just to show how icons in different folders are merged into different symbols.
  33. svgSprite([
  34. { inFile: 'src/assets/Heroicons', outFile: 'public/fonts', fileName: 'Heroicons' },
  35. { inFile: 'src/assets/IconPark', outFile: 'public/fonts', fileName: 'IconPark' },
  36. { inFile: 'src/assets/Remix', outFile: 'public/fonts', fileName: 'Remix' },
  37. ]),
  38. ],
  39. });