plg.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Custom vite plugins to build the web-client components of the simple theme.
  3. *
  4. * HINT:
  5. *
  6. * This is an inital implementation for the migration of the build process
  7. * from grunt to vite. For fully support (vite: build & serve) more work is
  8. * needed.
  9. */
  10. import { svg2png } from "./img.js";
  11. import { svg2svg } from "./img.js";
  12. /**
  13. * Vite plugin to convert a list of SVG files to PNG.
  14. *
  15. * @param {import('./img.js').Src2Dest} items - Array of SVG files (src: SVG, dest:PNG) to convert.
  16. */
  17. function plg_svg2png(items) {
  18. return {
  19. name: 'searxng-simple-svg2png',
  20. apply: 'build', // or 'serve'
  21. async writeBundle() { svg2png(items); },
  22. };
  23. }
  24. /**
  25. * Vite plugin to optimize SVG images for WEB.
  26. *
  27. * @param {import('svgo').Config} svgo_opts - Options passed to svgo.
  28. * @param {import('./img.js').Src2Dest} items - Array of SVG files (src:SVG, dest:SVG) to optimize.
  29. */
  30. function plg_svg2svg(svgo_opts, items) {
  31. return {
  32. name: 'searxng-simple-svg2png',
  33. apply: 'build', // or 'serve'
  34. async writeBundle() { svg2svg(items, svgo_opts); },
  35. };
  36. }
  37. export { plg_svg2png, plg_svg2svg };