gem-mine / webpack-css-themes-plugin

7 stars 2 forks source link

Work with CSS Modules #2

Closed itayganor closed 4 years ago

itayganor commented 4 years ago

Hi there :)

Is there any way to configure this plugin to work with CSS Modules enabled?

(I'm using less, if it matters)

Thanks!

githoniel commented 4 years ago

it should work and there is test case less-theme-less-loader-multi-loader.

if it does not work, re-open this and provide a re-produce repo, great thanks

itayganor commented 4 years ago

I made a minimal example by striping down everything unrelated from my project: https://github.com/itayganor/webpack-css-themes-plugin-reproduction

I receive the following error:

(node:16580) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'light' of undefined
itayganor commented 4 years ago

Investigation progress

It seems like the arrayed entry causes the problem. when I switch to an object entry, it successfully compiles.

The thing is that According to react-hot-loader docs the order of react-hot-loader/patch before the app itself is important.


I changed

entry: [
    'react-hot-loader/patch',
    './src/index.tsx'
],

to:

entry: {
    main: ['react-hot-loader/patch', './src/index.tsx'],
},

It compiles successfully, but since excludeAssets: [/\.css$/],, I have zero style tags in the page.

I'd imagined there will be a default theme applied

itayganor commented 4 years ago

Closing since I have gone through major progress in it.