lukeed / pwa

(WIP) Universal PWA Builder

Home Page:https://pwa.cafe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] import css from module

tuananh opened this issue · comments

i'm using a library and it requires me to load some css like this import 'react-day-picker/lib/style.css';

I'm using pwa with preact preset and sass. however, adding the above doesn't import the css for me.

I'm reading pwa/core but couldn't figure it out.

With sass-loader I know you need to import with ~ prefix, but it looks like this is still a bug with native CSS imports.

You can try the above and let me know, but I'm going to dig thru this tonight. There seems to be a lot of similar issues in Webpack issues. 😕

I tried that and still getting Module not found: Can't resolve '~react-day-picker/lib/style.css' error

Yeah, unfortunately that's what I was getting with native CSS modules here.

I'm currently passed that error – it can now resolve the style imports but it doesn't actually allow the vendor styles into the bundle.*.css output. 👎

As a quick "workaround" (maybe) you can try aliasing the vendor lib directly... but I fear you'll run into the same phantom/disappearing styles that I saw earlier.

module.exports = function (config) {
  config.resolve.alias['react-day-picker'] = join(__dirname, 'node_modules/react-day-picker');
}

Looking into it tonight