JSPM

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

Ignore imported style files when running in Node

Package Exports

  • ignore-styles

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 (ignore-styles) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ignore-styles

Version Build Status License Downloads

A babel/register style hook to ignore style imports when running in Node. This is for projects that use something like Webpack to enable CSS imports in JavaScript. When you try to run the project in Node (to test in Mocha, for example) you'll see errors like this:

SyntaxError: /Users/brandon/code/my-project/src/components/my-component/style.sass: Unexpected token (1:0)
> 1 | .title
| ^
2 |   font-family: serif
3 |   font-size: 10em
4 |

To resolve this, require ignore-styles with your mocha tests:

mocha --require ignore-styles

See DEFAULT_EXTENSIONS for the full list of extensions ignored, and send a pull request if you need more.

More Examples

To use this with multiple Mocha requires:

mocha --require babel-register --require ignore-styles

You can also use it just like babel/register:

    import 'ignore-styles'

In ES5:

    require('ignore-styles')

To customize the extensions used:

    import register from 'ignore-styles'
    register(['.sass', '.scss'])

To customize the extensions in ES5:

    require('ignore-styles')(['.sass', '.scss'])

Enjoy!