vite.config.js 1.9 KB

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