Webpack loader and plugin for processing .lass files. Transforms Lass source to CSS via @lass-lang/core.
npm install @lass-lang/webpack-plugin-lass css-loader mini-css-extract-plugin --save-dev// webpack.config.js
const { LassPlugin } = require('@lass-lang/webpack-plugin-lass');
module.exports = {
plugins: [new LassPlugin()],
};The plugin auto-configures module.rules for .lass files.
The lass loader returns JS (not CSS). It injects inline CSS imports using
webpack's !=! matchResource syntax. Those imports are handled by your
existing CSS rules (css-loader + MiniCssExtractPlugin).
// webpack.config.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
module: {
rules: [
{
test: /\.lass$/,
use: ['@lass-lang/webpack-plugin-lass'],
type: 'javascript/auto',
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
plugins: [new MiniCssExtractPlugin()],
};Then import .lass files directly:
import './styles.lass';CSS Modules work with .module.lass files:
import styles from './component.module.lass';
element.className = styles.container;For TypeScript, add declarations:
// lass.d.ts
declare module '*.lass';
declare module '*.module.lass' {
const classes: { readonly [key: string]: string };
export default classes;
}// Loader options
{
verbose: true, // Enable logging (default: false)
useJS: false, // Use JavaScript mode instead of TypeScript (default: false)
}Uses the Svelte-style self-referencing loader pattern:
- First pass: Loader transpiles
.lasssource to JS module via@lass-lang/core - Executes JS module to extract CSS string (base64 data: URL)
- Caches CSS and returns JS code with self-referencing inline import
- Second pass: Loader returns cached CSS to webpack's CSS pipeline
- Preamble imports are preserved in webpack's module graph (watch/HMR)
webpack>=5.0.0
MIT