You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

esm-loader-css

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esm-loader-css

Chainable ESModule Loader for CSS and Preprocessors

1.0.6
latest
Source
npmnpm
Version published
Weekly downloads
1.2K
-14.66%
Maintainers
1
Weekly downloads
 
Created
Source

esm-loader-css

Node.js ESModule Loader for CSS and related preprocessor stylesheets.

Supported stylesheet filename extensions: .css .less .pcss .postcss .sass .scss .sss .styl

Warning! Using experimental Node.js features and flags, API will likely change. This may be helpful for development and testing, but should not be used in production.

Usage

npm install --save-dev esm-loader-css

We want to import a .css file with Node.js:

/* index.css */
body {
  color: blue;
}
// index.js
import styles from './index.css'

console.dir(styles)
// "body { color: blue }"

Standalone

# node >= 20.7
cat << EOF > ./register.js
import { register } from 'node:module'
register('esm-loader-css', import.meta.url)
EOF
NODE_OPTIONS="--import ./register.js" node index.js

# node < 20.7
NODE_OPTIONS="--loader esm-loader-css" node index.js

Chainable

This loader can be configured, and chained with other loaders, using node-esm-loader.

npm install --save-dev node-esm-loader
// .loaderrc.js
export default {
  loaders: ['esm-loader-css'],
}
# node >= 20.7
NODE_OPTIONS="--import node-esm-loader/register" node index.js

# node < 20.7
NODE_OPTIONS="--loader node-esm-loader" node index.js

Options

Debug
// .loaderrc.js
export default {
  loaders: [
    {
      loader: 'esm-loader-css',
      options: {
        debug: true,
      },
    },
  ],
}

Future

  • Allow customization of valid css filename extensions list via .loaderrc config file?

License

MIT

Keywords

esm

FAQs

Package last updated on 01 Nov 2023

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