> ## Documentation Index
> Fetch the complete documentation index at: https://extension.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Extension.js needs Node.js 22.12 or newer; Node.js 18 and 20 do not work. It also runs on Deno 2.5+ and Bun 1.2+.
> The default browser target is chromium and a build lands in dist/<browser>, so dist/chromium by default. extension build writes a zip only when --zip is passed.
> Prefix a manifest key with a browser name when browsers differ. chromium: covers every Chromium-family target and Safari builds read it too. Since 4.1.19 chrome: means Chrome alone and edge: means Edge alone.
> Write one background.service_worker in manifest.json instead of hand-writing per-browser background keys; Extension.js converts it for each browser.
> package.json or deno.json marks the project root, not manifest.json. A config file is optional, and only extension.config.js, .mjs and .cjs are loaded, never .ts.
> The bundler is Rspack, extended through the config hook in extension.config.js. A project needs no separate bundler config file.
> Use --no-browser to skip the browser launch; --no-runner no longer exists and --no-open still launches the browser. Use --output for machine output; --format and --wait-format are deprecated.

# Sass and SCSS Modules in browser extensions

> Scale browser extension styling with Sass variables, nesting, and SCSS Modules. Extension.js supports .scss, .sass, and .module variants via Rspack.

Use Sass to scale browser extension styling with variables, nesting, and SCSS Modules while keeping a single build workflow.

Extension.js supports `.scss` and `.sass`, plus SCSS module variants (`.module.scss`, `.module.sass`) through the Rspack-based style pipeline.

## When Sass is a good fit

* Your design system already relies on Sass variables and mixins.
* You need modular styles for component-driven extension UIs.
* You want parity with existing Sass workflows in web applications.

## Template examples

### `new-sass`

![new-sass template screenshot](https://mintcdn.com/extensionjs/etcqPhDg4wwyPkcC/images/examples/newtab-sass/screenshot.png?fit=max\&auto=format\&n=etcqPhDg4wwyPkcC\&q=85\&s=f4951d5a05864f5475900bdcdd3f5f52)

Start a new-tab extension with Sass support already configured.

```bash npm theme={null}
npx extension@latest create my-extension --template=newtab-sass
```

```bash pnpm theme={null}
pnpx extension@latest create my-extension --template=newtab-sass
```

```bash yarn 2+ theme={null}
yarn dlx extension@latest create my-extension --template=newtab-sass
```

```bash bun theme={null}
bunx extension@latest create my-extension --template=newtab-sass
```

```bash deno theme={null}
deno run -A npm:extension@latest create my-extension --template=newtab-sass
```

Repository: [extension-js/templates/newtab-sass](https://github.com/extension-js/templates/tree/main/examples/newtab-sass)

## Usage with an existing extension

Add Sass to an existing extension with the steps below.

### Installation

Install the required dependency:

```bash npm theme={null}
npm install -D sass
```

```bash pnpm theme={null}
pnpm add -D sass
```

```bash yarn theme={null}
yarn add -D sass
```

```bash bun theme={null}
bun add -d sass
```

```bash deno theme={null}
deno add -D npm:sass
```

### Example usage in an HTML file

In extension pages (popup/options/new tab), import Sass from your entry script:

```html theme={null}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>New Extension</title>
    <script src="./main.ts"></script>
  </head>
  <body>
    <h1 class="title">Hello, Extension.</h1>
  </body>
</html>
```

```ts theme={null}
import "./styles/globals.scss";

console.log("Sass loaded");
```

## Sass modules

Scope styles locally with Sass modules, just like CSS Modules. Use `.module.scss` or `.module.sass` to activate scoping and prevent naming conflicts in your stylesheets.

### `content-sass-modules`

![content-sass-modules template screenshot](https://mintcdn.com/extensionjs/VCnDd7fX2Nza24SE/images/examples/content-sass-modules/screenshot.png?fit=max\&auto=format\&n=VCnDd7fX2Nza24SE\&q=85\&s=db5f350d56fd869acc019bda11ffb989)

Use Sass modules in content scripts when you need scoped styling for injected UI.

```bash npm theme={null}
npx extension@latest create my-extension --template=content-sass-modules
```

```bash pnpm theme={null}
pnpx extension@latest create my-extension --template=content-sass-modules
```

```bash yarn 2+ theme={null}
yarn dlx extension@latest create my-extension --template=content-sass-modules
```

```bash bun theme={null}
bunx extension@latest create my-extension --template=content-sass-modules
```

```bash deno theme={null}
deno run -A npm:extension@latest create my-extension --template=content-sass-modules
```

Repository: [extension-js/templates/content-sass-modules](https://github.com/extension-js/templates/tree/main/examples/content-sass-modules)

## Using Sass modules in an existing extension

To enable Sass modules, rename your Sass file to include `.module.scss` or `.module.sass`. This automatically scopes the styles to your component.

```diff theme={null}
- button.scss
+ button.module.scss
```

### Example usage

After renaming your Sass file, import it into your script:

```ts theme={null}
import styles from "./styles/button.module.scss";

const element = document.createElement("h1");
element.className = styles.primaryColor;
element.innerText = "Hello, Extension!";
document.body.appendChild(element);
```

In the Sass file:

```scss theme={null}
/* styles/button.module.scss */

$primary-color: #64ff00;

:export {
  primaryColor: $primary-color;
}
```

## React/Preact example usage

Import the Sass module into your React or Preact component, and use the scoped class names:

```jsx theme={null}
import styles from "./styles/button.module.scss";

export default function MyComponent() {
  return <h1 className={styles.primaryColor}>Hello, Extension!</h1>;
}
```

## Vue example usage

In Vue SFCs, prefer module styles with `lang="scss"`:

```vue theme={null}
<template>
  <h1 :class="$style.primaryColor">Hello, Extension!</h1>
</template>

<style lang="scss" module>
@import "./styles/button.module.scss";
</style>
```

## Svelte example usage

In Svelte, import Sass module mappings and apply classes:

```svelte theme={null}
<script>
  import styles from "./styles/button.module.scss";
</script>

<h1 class={styles.primaryColor}>Hello, Extension!</h1>
```

## Behavior notes

* In extension pages, `.module.scss` and `.module.sass` export class maps for JS/TS imports.
* In content scripts, Extension.js emits Sass as CSS assets without JavaScript class-name mappings.
* If the `sass` package is not installed, Extension.js warns and copies the raw Sass source into the output CSS, so those surfaces render unstyled until you install it yourself.

## Next steps

* Learn more about [CSS Modules](https://extension.js.org/docs/languages-and-frameworks/css-modules.md).
* Ensure stylesheet quality with [Stylelint](https://extension.js.org/docs/integrations/stylelint.md).

## Video walkthrough

[Extension.js: New Tab Sass template](https://www.youtube-nocookie.com/embed/bUWLBJeWzpc?rel=0)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.