Skip to content

Commit

Permalink
build: adapt new vite version
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Sep 7, 2024
1 parent a19394c commit 8aa62ce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { crx } from "@crxjs/vite-plugin";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { defineConfig, Plugin } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import pkg from "./package.json";

// https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919
const viteManifestHackIssue846: Plugin & { renderCrxManifest: (manifest: any, bundle: any) => void } = {
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
name: "manifestHackIssue846",
renderCrxManifest(_manifest, bundle) {
bundle["manifest.json"] = bundle[".vite/manifest.json"];
bundle["manifest.json"].fileName = "manifest.json";
delete bundle[".vite/manifest.json"];
},
};

export default defineConfig((env) => ({
resolve: {
alias: {
Expand All @@ -14,6 +25,7 @@ export default defineConfig((env) => ({
drop: env.command === "build" ? ["console", "debugger"] : [],
},
plugins: [
viteManifestHackIssue846,
react(),
crx({
manifest: {
Expand Down

0 comments on commit 8aa62ce

Please sign in to comment.