liady / webpack-node-externals

Easily exclude node modules in Webpack
MIT License
1.3k stars 62 forks source link

How can I bundle assets (i.e css files) from node_modules that required in node_modules? #127

Open krutoo opened 1 year ago

krutoo commented 1 year ago

Hi, i use example from here:

https://github.com/liady/webpack-node-externals#how-can-i-bundle-required-assets-ie-css-files-from-node_modules

But looks like it works only when css file import places at source code of project

It is not working when i import file from node_modules that imports css file

How can i fix that?

Example of source code:

// import css WORKS
import "./test.css";

// import css-modules WORKS
import styles from "./test.module.css";

// import css-modules from node_modules WORKS
import somethingStyles from "some-lib/something/something.module.scss";

// import module from node_modules that has imports of css-modules ERROR
import { Something } from "some-lib/something";

Example of webpack config:

{
  target: 'node',
  externalsPresets: { node: true },
  externals: nodeExternals({
    allowlist: [/\.(?!(?:js|json)$).{1,5}$/i],
  }),
  // ...
}
sushmitg commented 1 year ago

I am having similar issue with 'react-day-picker' v7