JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1943
  • Score
    100M100P100Q116470F
  • License MIT

Chainable ESModule Loader for CSS and Preprocessors

Package Exports

  • esm-loader-css
  • esm-loader-css/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (esm-loader-css) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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_OPTIONS="--experimental-loader esm-loader-css" node index.js

Chainable

This loader can be configured, and chained with other loaders, using node-esm-loader. This should be your only loader handling stylesheet files.

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

Option: 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