vite.js 923 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { readFileSync } from "node:fs"
  2. import solidPlugin from "vite-plugin-solid"
  3. import tailwindcss from "@tailwindcss/vite"
  4. import { fileURLToPath } from "url"
  5. const theme = fileURLToPath(new URL("./public/oc-theme-preload.js", import.meta.url))
  6. /**
  7. * @type {import("vite").PluginOption}
  8. */
  9. export default [
  10. {
  11. name: "opencode-desktop:config",
  12. config() {
  13. return {
  14. resolve: {
  15. alias: {
  16. "@": fileURLToPath(new URL("./src", import.meta.url)),
  17. },
  18. },
  19. worker: {
  20. format: "es",
  21. },
  22. }
  23. },
  24. },
  25. {
  26. name: "opencode-desktop:theme-preload",
  27. transformIndexHtml(html) {
  28. return html.replace(
  29. '<script id="oc-theme-preload-script" src="/oc-theme-preload.js"></script>',
  30. `<script id="oc-theme-preload-script">${readFileSync(theme, "utf8")}</script>`,
  31. )
  32. },
  33. },
  34. tailwindcss(),
  35. solidPlugin(),
  36. ]