This is an example of importing a CSS file located inside node_modules (ones you downloaded using npm or yarn).
This would be useful for importing CSS libraries such as normalize.css.
Check out the with-global-stylesheet example.
- Install
babel-plugin-inline-importusingnpmoryarn - Then, add this to your
.babelrc:
{
"plugins": [
[
"inline-import",
{
"extensions": [".css"]
}
]
],
"presets": ["next/babel"],
"ignore": []
}- Install any CSS library using
npmoryarn. In this example, I installedtachyons. - Import the CSS file. Here, I'm importing a CSS file located at
node_modules/tachyons/css/tachyons.min.css.
import tachyons from 'tachyons/css/tachyons.min.css'- Add it globally using
styled-jsx:
<style jsx global>{tachyons}</style>