yosevu / react-content-script

An example project to build Chrome extensions using React and TypeScript. Ideal for developers looking to create efficient and modern Chrome extensions with a focus on a clean development workflow using Vite and crxjs.
202 stars 56 forks source link

Error occurs while build #19

Closed iammohan01 closed 8 months ago

iammohan01 commented 8 months ago

I Just Migrated from JS to TS.

I tried this tool, But when i try to build using this got error like this

[crx:content-script-resources] Error: vite manifest is missing
    at Object.renderCrxManifest (file:///Users/mohanasundaram/slashSpaceGo/node_modules/@crxjs/vite-plugin/dist/index.mjs:3240:21)
    at Object.generateBundle (file:///Users/mohanasundaram/slashSpaceGo/node_modules/@crxjs/vite-plugin/dist/index.mjs:2922:60)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Bundle.generate (file:///Users/mohanasundaram/slashSpaceGo/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:16973:9)
    at async file:///Users/mohanasundaram/slashSpaceGo/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19519:27
    at async catchUnfinishedHookActions (file:///Users/mohanasundaram/slashSpaceGo/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18950:16)
    at async build (file:///Users/mohanasundaram/slashSpaceGo/node_modules/vite/dist/node/chunks/dep-4RECYSE1.js:66261:22)
    at async CAC.<anonymous> (file:///Users/mohanasundaram/slashSpaceGo/node_modules/vite/dist/node/cli.js:845:9)
[crx:manifest-post] Error in crx:content-script-resources.renderCrxManifest
✓ built in 2.32s

Manifest Json Included.

manifest.json

import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import {viteStaticCopy} from 'vite-plugin-static-copy';
import {join, resolve} from "path"
import Checker from 'vite-plugin-checker';
import svgr from "vite-plugin-svgr";
import {crx} from "@crxjs/vite-plugin";
import manifest from "./manifest.json"

export default defineConfig({
    plugins: [
        react(),
        Checker({typescript: true}),
        svgr({
            svgrOptions: {
                icon: true,
            },
        }),
        crx({ manifest }),
        viteStaticCopy({
            targets: [
                {
                    src: 'manifest.json',
                    dest: '.'
                }
            ]
        })
    ],
    build: {
        minify: false,
        chunkSizeWarningLimit: 500,
        copyPublicDir: false,
        emptyOutDir: true,
        outDir: join(__dirname, "build"),
        rollupOptions: {
            external: [
                'Shortcuts.json'
            ],
            input: {
                admin_page: resolve(__dirname, 'index.html'),
                popup: resolve(__dirname, 'popup.html'),
                background: resolve(__dirname, 'src/chrome/background.ts'),
                SlashSpaceGoHelper: resolve(__dirname, 'src/chrome/SlashSpaceGoHelper.ts')
            },
            output: {
                entryFileNames: 'scripts/[name].js',
                assetFileNames: 'assets/[name].[ext]',
                chunkFileNames: "scripts/[name].js"
            }
        }
    }
});
iammohan01 commented 8 months ago

Fixed by rewriting everything from start