plg.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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, svg2svg } from "./img.js";
  11. /**
  12. * Vite plugin to convert a list of SVG files to PNG.
  13. *
  14. * @param {import('./img.js').Src2Dest[]} items - Array of SVG files (src: SVG, dest:PNG) to convert.
  15. */
  16. function plg_svg2png(items) {
  17. return {
  18. name: "searxng-simple-svg2png",
  19. apply: "build", // or 'serve'
  20. async writeBundle() {
  21. await svg2png(items);
  22. }
  23. };
  24. }
  25. /**
  26. * Vite plugin to optimize SVG images for WEB.
  27. *
  28. * @param {import('./img.js').Src2Dest[]} items - Array of SVG files (src:SVG, dest:SVG) to optimize.
  29. * @param {import('svgo').Config} svgo_opts - Options passed to svgo.
  30. */
  31. function plg_svg2svg(items, svgo_opts) {
  32. return {
  33. name: "searxng-simple-svg2png",
  34. apply: "build", // or 'serve'
  35. async writeBundle() {
  36. await svg2svg(items, svgo_opts);
  37. }
  38. };
  39. }
  40. export { plg_svg2png, plg_svg2svg };