2024-02-12 14:30:23 +03:00
|
|
|
import { crx } from '@crxjs/vite-plugin';
|
|
|
|
import react from '@vitejs/plugin-react';
|
2024-02-25 19:32:08 +03:00
|
|
|
import { defineConfig, Plugin } from 'vite';
|
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
2024-02-12 14:30:23 +03:00
|
|
|
|
|
|
|
import manifest from './src/manifest';
|
|
|
|
|
|
|
|
const viteManifestHack: Plugin & {
|
|
|
|
renderCrxManifest: (manifest: unknown, bundle: unknown) => void;
|
|
|
|
} = {
|
|
|
|
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
|
|
|
|
name: 'manifestHack',
|
2024-02-25 19:32:08 +03:00
|
|
|
renderCrxManifest: (_manifest, bundle: any) => {
|
2024-02-12 14:30:23 +03:00
|
|
|
bundle['manifest.json'] = bundle['.vite/manifest.json'];
|
|
|
|
bundle['manifest.json'].fileName = 'manifest.json';
|
|
|
|
delete bundle['.vite/manifest.json'];
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default defineConfig(() => {
|
|
|
|
return {
|
2024-05-06 12:33:48 +03:00
|
|
|
root: __dirname,
|
|
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-chrome-extension',
|
|
|
|
|
2024-02-12 14:30:23 +03:00
|
|
|
build: {
|
|
|
|
emptyOutDir: true,
|
|
|
|
outDir: 'dist',
|
|
|
|
rollupOptions: {
|
|
|
|
output: { chunkFileNames: 'assets/chunk-[hash].js' },
|
|
|
|
},
|
2024-03-26 16:37:36 +03:00
|
|
|
target: 'ES2022',
|
2024-02-12 14:30:23 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// Adding this to fix websocket connection error.
|
|
|
|
server: {
|
|
|
|
port: 3002,
|
|
|
|
strictPort: true,
|
|
|
|
hmr: { port: 3002 },
|
|
|
|
},
|
|
|
|
|
2024-02-25 19:32:08 +03:00
|
|
|
plugins: [viteManifestHack, crx({ manifest }), react(), tsconfigPaths()],
|
2024-02-12 14:30:23 +03:00
|
|
|
};
|
|
|
|
});
|