Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alexperezortuno/ce-blocker/llms.txt

Use this file to discover all available pages before exploring further.

vite.config.ts configures the Vite build for two entry points — the popup and the background service worker — and sets a Bootstrap path alias for SCSS imports. It imports readJsonFile from vite-plugin-web-extension to power the generateManifest() helper, which merges package.json metadata into dist/manifest.json on every build. Note that the webExtension plugin itself is not added to the plugins array — only vue() is registered there.

Full Configuration

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import webExtension, {readJsonFile} from "vite-plugin-web-extension";
import * as path from "node:path";

function generateManifest() {
    const manifest = readJsonFile("src/manifest.json");
    const pkg = readJsonFile("package.json");
    return {
        name: pkg.name,
        description: pkg.description,
        version: pkg.version,
        ...manifest,
    };
}

export default defineConfig({
    plugins: [
        vue(),
    ],
    resolve: {
        alias: {
            '~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
        }
    },
    build: {
        target: "esnext",
        rollupOptions: {
            input: {
                popup: "index.html",
                background: "src/background/background.ts",
            },
            output: {
                entryFileNames: "assets/[name].js"
            }
        }
    }
});

Key Settings

plugins: [vue()]
plugin
Enables Vue 3 Single File Component (SFC) compilation. All .vue files in src/ are processed by @vitejs/plugin-vue during bundling.
resolve.alias['~bootstrap']
string
Maps the ~bootstrap prefix to the Bootstrap package in node_modules/. This allows SCSS files to use concise imports such as @import '~bootstrap/scss/bootstrap' without needing to resolve the full node_modules path manually.
build.target
string
Set to "esnext" to target modern, evergreen browsers. Chrome extensions run exclusively in Chrome, which fully supports the latest ECMAScript features, so no legacy transpilation is needed.
rollupOptions.input.popup
string
The popup entry point: "index.html". Rollup bundles this HTML file and all its imported scripts and styles into dist/, producing the popup UI loaded when the user clicks the toolbar icon.
rollupOptions.input.background
string
The service worker entry point: "src/background/background.ts". This module runs as the MV3 background service worker and handles declarativeNetRequest rule management.
rollupOptions.output.entryFileNames
string
The output filename pattern "assets/[name].js" causes Rollup to emit the two entry points as assets/popup.js and assets/background.js. The background.js path matches the value declared in manifest.json under background.service_worker.
The entryFileNames pattern ensures the background service worker is always output as assets/background.js, matching the path declared in manifest.json. Changing either value without updating the other will prevent the service worker from loading in Chrome.

Build docs developers (and LLMs) love