{"id":25453,"library":"esbuild-style-loader","title":"esbuild-style-loader","description":"A style loader plugin for esbuild that supports CSS, SCSS, LESS, Stylus, and CSS Modules. Current stable version is 0.3.4. It uses lightningcss for fast CSS processing and includes autoprefixer with sensible defaults (ios >= 11, android >= 5, chrome >= 54). Unlike other esbuild CSS plugins, it offers zero-config setup, built-in CSS Modules support for files matching .module.css or ?modules query, and handles multiple preprocessors via built-in loaders (LESS built-in, sass via peer dep). Released under MIT license with TypeScript types included.","status":"active","version":"0.3.4","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/noyobo/esbuild-style-loader","tags":["javascript","esbuild","esbuild-loader","esuild-css-modules","typescript"],"install":[{"cmd":"npm install esbuild-style-loader","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-style-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-style-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to work","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only since v0.3.3; named export, not default.","wrong":"const styleLoader = require('esbuild-style-loader')","symbol":"styleLoader","correct":"import { styleLoader } from 'esbuild-style-loader'"},{"note":"CommonJS destructured import works; no default export.","wrong":"const styleLoader = require('esbuild-style-loader').default","symbol":"styleLoader","correct":"const { styleLoader } = require('esbuild-style-loader')"},{"note":"Type-only import for TypeScript users.","wrong":"","symbol":"StyleLoaderOptions","correct":"import type { StyleLoaderOptions } from 'esbuild-style-loader'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { styleLoader } from 'esbuild-style-loader';\n\nbuild({\n  entryPoints: ['src/app.js'],\n  bundle: true,\n  outdir: 'dist',\n  plugins: [\n    styleLoader({\n      filter: /\\.(css|less|scss|sass)(\\?.*)?$/,\n    }),\n  ],\n}).catch(() => process.exit(1));","lang":"typescript","description":"Sets up esbuild with the style loader plugin, bundling CSS imports from app.js and outputting to dist/"},"warnings":[{"fix":"Switch to ESM imports: import { styleLoader } from 'esbuild-style-loader'","message":"v0.3.3 removed CJS support for ESM-only builds; update imports accordingly.","severity":"breaking","affected_versions":">=0.3.3"},{"fix":"Use cssModules: { pattern: '[local]__[hash]' } instead of cssModules: true","message":"Passing 'true' for cssModules option is deprecated; use an object with 'pattern'","severity":"deprecated","affected_versions":"<0.3.4"},{"fix":"Rename file to .module.css or append ?modules query","message":"CSS Modules only work for files matching .module.css or ?modules query; normal imports are treated as global CSS","severity":"gotcha","affected_versions":"all"},{"fix":"Install sass: npm install sass","message":"Sass requires the 'sass' peer dependency; node-sass and sass-embedded are not supported","severity":"gotcha","affected_versions":"all"},{"fix":"Explicitly set namespace if relying on old behavior","message":"The 'namespace' option default changed from 'file' to ['native-component', 'file']","severity":"deprecated","affected_versions":">=0.3.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install esbuild-style-loader","cause":"Package not installed","error":"Error: Cannot find module 'esbuild-style-loader'"},{"fix":"Use import { styleLoader } from 'esbuild-style-loader'","cause":"Using require() with ESM-only version (v0.3.3+)","error":"Error: Must use import to load ES Module: esbuild-style-loader"},{"fix":"Use named import: import { styleLoader } from 'esbuild-style-loader'","cause":"Importing wrong symbol or default export","error":"TypeError: styleLoader is not a function"},{"fix":"Rename to style.module.css or import with ?modules","cause":"File name does not match .module.css or query","error":"CSS Modules file './style.css' imported with styleLoader but not treated as module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}