Socket
Book a DemoInstallSign in
Socket

esbuild-stylus-loader

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-stylus-loader

esbuild plugin for stylus files

0.4.6
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

esbuild-stylus-loader

Esbuild plugin for stylus files.

Installation

npm install esbuild-stylus-loader stylus

or

yarn add esbuild-stylus-loader stylus

Example

build.js

const {build} = require('esbuild')
const {stylusLoader} = require('esbuild-stylus-loader')

build({
    entryPoints: [
        'src/index.js',
    ],
    bundle: true,
    outdir: 'dist',
    plugins: [
        stylusLoader({
            stylusOptions: {
                define: [
                    ['BG_IMAGE', 'https://domain.com/image.jpeg'],
                ],
            },
        })
    ],
}).then(result => {})

src/index.js

import './style.styl'
console.log('hello world')

src/style.styl

html
    background-image url(BG_IMAGE)

command line

node ./build.js

Arguments

stylusLoader({
    stylusOptions: {
        /**
         * @see https://stylus-lang.com/docs/js.html#includepath
         * @type {string[]}
         */
        include: ['./some/path'],

        /**
         * @see https://stylus-lang.com/docs/js.html#importpath
         * @type {string[]}
         */
        import: [
            path.resolve(__dirname, 'path'),
            path.resolve(__dirname, 'another-path'),
        ],

        /**
         * @see https://stylus-lang.com/docs/js.html#usefn
         * @type {Function[]}
         */
        use: [
            (stylus) => {
                stylus.define('URL', 'domain.com')
            },
        ],

        /**
         * @see https://stylus-lang.com/docs/js.html#definename-node
         * @type {[string, any, boolean?][]}
         */
        define: [
            ['BG_IMAGE', 'https://domain.com/image.jpeg'],
            /** The third argument allows to insert raw data */
            ['BG_IMAGE', 'https://domain.com/image.jpeg', true],
        ],

        /**
         * Stylus will include css file content via @import "./file.css" keyword.
         * @type {boolean}
         */
        includeCss: false,
    },
})

Keywords

esbuild

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.