Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

esbuild-style-loader

noyobo866MIT0.3.4TypeScript support: included

A style loader for esbuild, support for CSS, SCSS, LESS, Stylus, and CSS Modules.

esbuild, esbuild-loader, esuild-css-modules

readme

esbuild-style-loader

npm version License: MIT issues PRs Welcome downloads Code Coverage Node.js CI

A style loader for esbuild, support for CSS, SCSS, LESS, Stylus, and CSS Modules.

Features

  • <input checked="" disabled="" type="checkbox"> Zero configuration
  • <input checked="" disabled="" type="checkbox"> Support for CSS Modules
  • <input checked="" disabled="" type="checkbox"> Support for LESS builtin
  • <input checked="" disabled="" type="checkbox"> Support for CSS
  • <input checked="" disabled="" type="checkbox"> Autoprefixer for CSS
    • default: ios >= 11, android >= 5, chrome >= 54
  • <input checked="" disabled="" type="checkbox"> Support sourceMap
  • <input checked="" disabled="" type="checkbox"> Fast compiler engine by lightningcss

Default behavior

The following rules enable css-modules

  1. The file name ends with /.modules?\.(css|less|scss|sass|styl)/
  2. The file query contains modules or modules=true
import styles from './style.css?modules';
import styles from './style.module.css';
import styles from './style.modules.css';
import styles from './style.less?modules';
import styles from './style.module.less';
import styles from './style.modules.less';

Normal CSS files are not treated as CSS Modules

import './style.css';
import './style.less';
import styles from './style.css';
import styles from './style.less';

Usage

import { build } from 'esbuild';
import { styleLoader } from 'esbuild-style-loader';

const buildOptions = {
  plugins: [
    styleLoader({
      filter: /\.(css|less|scss|sass|tyss)(\?.*)?$/,
      /**
       * Process file results from other plugins namespace
       */
      namespace: ['native-component', 'file'],
      /**
       * The browser setting for lightningcss
       */
      browsers: 'ios >= 11, android >= 5, chrome >= 54',
      cssModules: {
        pattern: process.env.CI_TEST === 'test' ? '[name]__[local]' : '[local]__[hash]',
      },
      /**
       * The public path for absolute paths in css
       */
      publicPath: __dirname,
    }),
  ],
};

if you want to use absolute paths, you can specify the publicPath option

TODO

  • <input disabled="" type="checkbox"> Support for Stylus
  • <input disabled="" type="checkbox"> Support for Sass
    • <input checked="" disabled="" type="checkbox"> sass
    • <input disabled="" type="checkbox"> node-sass
    • <input disabled="" type="checkbox"> sass-embedded

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.3.4 (2024-12-18)

Bug Fixes

0.3.3 (2024-12-18)

Bug Fixes

0.3.2 (2024-12-12)

Bug Fixes

0.3.1 (2024-06-21)

Bug Fixes

0.3.0 (2024-06-21)

Features

0.2.1 (2024-06-11)

0.2.0 (2024-03-04)

bump

BREAKING CHANGES

  • esbuild ^0.20.0

0.1.19 (2024-01-02)

Bug Fixes

0.1.18 (2023-11-14)

Bug Fixes

0.1.17 (2023-11-14)

Bug Fixes

  • watch mode file change not work (c12bf8b)

0.1.16 (2023-09-27)

Bug Fixes

  • update css minify missing quotes (e3c555b)

Features

  • options support publicPath static files root base (da18776)

0.1.15 (2023-09-27)

Bug Fixes

  • ignore css include absolute files (fc97fe0)

0.1.14 (2023-06-15)

Bug Fixes

0.1.13 (2023-06-08)

0.1.12 (2023-06-08)

0.1.11 (2023-06-06)

Features

0.1.10 (2023-06-02)

Bug Fixes

0.1.9 (2023-06-02)

Bug Fixes

0.1.8 (2023-06-02)

Features

  • css modules tree-shaking (f1c9e94)

0.1.7 (2023-06-01)

Bug Fixes

  • css-loader resolve static file (#8) (03cd1e2)

0.1.6 (2023-06-01)

Features

0.1.5 (2023-05-26)

Bug Fixes

  • css-loader resolve absolutePath (#6) (06fc57a)

0.1.4 (2023-05-25)

Features

0.1.3 (2023-05-25)

Bug Fixes

0.1.2 (2023-05-19)

Features

  • support less & css-modules & source-map (#1) (f037f39)