lukehedger / sip

🍹 Small sips of CSS
Other
4 stars 1 forks source link

Webpack2 import #12

Open balajmarius opened 7 years ago

balajmarius commented 7 years ago

I'm trying to use Sip.css with webpack 2 / react-create-app but the result of the import is a string.

import Sip from 'sip.css'

console.log(Sip) -> /static/media/sip.5c5e6212.mjs
console.log(typeof Sip) -> string

I am doing something wrong?

lukehedger commented 7 years ago

@balajmarius interesting - looks like it thinks 'sip.css' references a CSS file! Must be something to do with CRA webpack config, as works with a simple config.

balajmarius commented 7 years ago

You are right, CRA uses css-loader and sip.css is interpreted as a CSS file.

lukehedger commented 7 years ago

@balajmarius I guess if Sip is being used then so will a CSS-in-JS library, which means css-loader will not be needed? CRA users could then just run npm run eject and remove from Webpack config.

It is interesting that CSS-in-JS isn't the default for CRA but I imagine they wanted to keep it as simple as possible!