Skip to content

Commit

Permalink
fix: remove myPlugin from firefox vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
lahgolz authored and stepan662 committed Dec 16, 2024
1 parent ea86d4d commit c8ff703
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions vite.config.firefox.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,10 @@
import { defineConfig, Plugin } from 'vite';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { crx } from '@crxjs/vite-plugin';
import zipPack from 'vite-plugin-zip-pack';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import fs from 'node:fs';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import path from 'node:path';

import manifest from './manifest.json';

function myPlugin(): Plugin {
function updateManifest() {
const absolutePath = path.resolve('./dist-firefox/manifest.json');

const content = fs.readFileSync(absolutePath);
const test = JSON.parse(content);
test.web_accessible_resources = test.web_accessible_resources.map((i) => ({
...i,
use_dynamic_url: false,
}));
fs.writeFile(absolutePath, JSON.stringify(test, null, 2), (err) => {
if (err) {
console.error(err);
} else {
console.log('manifest.json updated');
}
});
}

return {
name: 'my-plugin',
generateBundle(options, bundle) {
console.log(bundle);
},
writeBundle() {
updateManifest();
},
};
}

// https://vitejs.dev/config/
export default defineConfig({
build: {
Expand All @@ -50,7 +14,6 @@ export default defineConfig({
plugins: [
react(),
crx({ manifest: manifest as any, browser: 'firefox' }),
myPlugin(),
zipPack({ inDir: 'dist-firefox', outFileName: 'firefox.zip' }),
],
});

0 comments on commit c8ff703

Please sign in to comment.