Skip to content

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

@krutoo

Description

@krutoo

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],
  }),
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions