esbuild-sass-plugin (ysink fork)

raw JSON →
2.3.4 verified Fri May 01 auth: no javascript

Fork of esbuild-sass-plugin (v2.3.4, actively maintained) adding CSS modules support without auto-injection, plus a shelter mode for Discord scoped APIs. Differentiates from upstream by allowing `inject: false` for modules and `inject: 'shelter'` for unloading. Ships TypeScript types, supports postcss, and targets esbuild plugin ecosystem.

error Error: Cannot find module 'esbuild-sass-plugin-ysink'
cause Package not installed or incorrect import path.
fix
Run npm install esbuild-sass-plugin-ysink and ensure import path matches.
error TypeError: sassPlugin is not a function
cause Importing default instead of named or using wrong package.
fix
Use import { sassPlugin } from 'esbuild-sass-plugin-ysink'.
error Error: Unsupported transform: postcssModules is not a function
cause postcssModules not imported or used incorrectly.
fix
Import postcssModules: import { postcssModules } from 'esbuild-sass-plugin-ysink' and pass as transform function.
error Error: [plugin: esbuild-sass-plugin] Expected 'inject' option
cause Missing `inject` property in postcssModules options.
fix
Add inject: false or inject: 'shelter' to postcssModules options.
deprecated Plugin options may change between minor versions; check changelog for breaking changes.
fix Pin version if stability needed.
gotcha When using `inject: false`, CSS modules return a string of CSS; you must handle insertion manually.
fix Use `type: 'css-text'` in esbuild config or manually inject via style tag.
breaking In v2.0, the transform API changed from `postcssModules()` to accept options object directly.
fix Update to new transform signature.
deprecated Older `inject: true` default is deprecated; future versions may require explicit `inject` setting.
fix Set `inject: false` or `inject: 'shelter'` as needed.
npm install esbuild-sass-plugin-ysink
yarn add esbuild-sass-plugin-ysink
pnpm add esbuild-sass-plugin-ysink

Builds a TypeScript app with SCSS and CSS modules using esbuild, injecting CSS as text string.

import esbuild from 'esbuild';
import { sassPlugin, postcssModules } from 'esbuild-sass-plugin-ysink';

await esbuild.build({
  entryPoints: ['src/app.ts'],
  bundle: true,
  outfile: 'dist/app.js',
  plugins: [
    sassPlugin({
      filter: /\.scss$/,
      transform: postcssModules({
        inject: false, // CSS modules without auto-injection
        localsConvention: 'camelCase'
      })
    })
  ]
});