Documentation Index
Fetch the complete documentation index at: https://mintlify.com/crxjs/chrome-extension-tools/llms.txt
Use this file to discover all available pages before exploring further.
Installation
This guide covers adding CRXJS Vite Plugin to an existing Vite project or setting up a new project from scratch.Prerequisites
Before installing CRXJS, ensure you have:- Node.js 14.18+ or 16+
- A Vite project (or create one using
npm create vite@latest)
Install the plugin
Install@crxjs/vite-plugin as a dev dependency:
Create a manifest
Create amanifest.json file in your project root. This file defines your extension’s metadata and entry points:
manifest.json
CRXJS supports Manifest V3, the latest version of the Chrome Extension manifest format with enhanced security features.
Manifest examples
Here are some common manifest configurations:Update Vite config
Import and configure the CRXJS plugin in yourvite.config.js or vite.config.ts:
TypeScript manifest (optional)
For better type safety and dynamic configuration, use a TypeScript manifest with thedefineManifest helper:
Dynamic manifest example
You can use environment variables and dynamic logic in your TypeScript manifest:manifest.config.ts
Run the development server
Start Vite’s development server:- Parse your manifest
- Build all entry files (HTML pages, scripts, etc.)
- Generate the
distfolder with your extension - Watch for changes and rebuild automatically
Load the extension
Enable developer mode
Toggle the “Developer mode” switch in the top right (Chrome) or left sidebar (Edge)
Verify installation
Your extension should appear in the extensions list with:- The name from your manifest
- An icon showing the first letter of your extension name (or your custom icon if specified)
- A toggle to enable/disable it
Next steps
Quick start tutorial
Follow the 90-second tutorial to experience HMR
Manifest concepts
Learn more about manifest configuration
Add content scripts
Inject scripts into web pages
Configuration options
Explore advanced plugin configuration
Troubleshooting
”type”: “module” error
If Vite can’t process your config file, ensure yourpackage.json includes:
package.json
Manifest paths not resolving
Manifest paths should be relative to your Vite project root and should NOT start with./ or /:
Extension not loading
If your extension doesn’t load in Chrome:- Check the browser console for errors
- Verify your
distfolder was generated - Ensure your manifest has at minimum:
manifest_version,name, andversion - Try removing and re-adding the extension