-
-
Notifications
You must be signed in to change notification settings - Fork 161
How to Ignore Third Party Component css files while using babel-plugin-react-css-modules #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can use the exclude option to exclude non css-modules stylesheets. You might also need to specify a name for each import. import list from "./css/list.rcss";
import fdt from "fixed-data-table.css";
export function () { return <div styleName="list.someStyleName" />;} |
Thanks, but I did try to exclude earlier, but exclude config expects a string as a value, and I need to pass a regEx (to remove the non css-modules stylesheets with extension .css as all my css-module stylesheets are with extension .rcss) Also, I can not specify a name for all the imports as I cannot apply the css for fixed-data-table using the name, it is imported so that the Fixed-DataTable Component can use it internally. |
The documentation says that excludes accepts a string RegEx so you should be able to write excludes: '\.css$' (I haven't tested this). I was suggesting supplying a name just to avoid confusing the css-modules plugin, if the CSS file is excluded from css-modules processing, it should be imported as a regular CSS file and the corresponding variable will be undefined. |
|
I cannot think of a way to do this from within the code-base. I cannot think of a clean way to implement this at the plugin either. Adding an option to ignore a pattern is an option, sure, but it is not in any way better than –
This will work, assuming that the sole intent is adding the style to the bundle. |
can add |
+1 to adding |
I shouldn't have to use babel-plugin-react-css-modules exclude option in babel.rc if I am excluding node modules in css modules loader in webpack config and running node-modules through different css loader, right? I'm confused because I am still getting this error when I also try to anonymously import a plugin css file. Tried naming each import
but I'm still getting the error... |
Does {
"plugins": [
["react-css-modules", {
"exclude": "node_modules"
}]
]
} but imports in the form of: import whatever from `../node_modules/cheers.css` are still CSS-Modulefied. Is this expected, am I doing something wrong, or is this a bug? |
Same issue as @flekschas. |
Same issue, "exclude": "node_modules" does nothing even though it's referenced in the docs. |
@blairvanderhoof @flekschas no double quotes! It's a regex ! |
@hpeikari no because the |
@flekschas @blairvanderhoof this is how I exluded node_modules and worked for me !
|
|
@hpeikari I believe this won't work because when you exclude the 'node_modules' folder from the loader options, than when webpack will scream that you need a loader to import .css files.
If not excluding the node_modules from the css loader options that the imported file from node_modules gets converted by the react-css-modules plugin :) The exclude option in the plugin configs does not work at all. |
I have this situation where in one of my Component JSX file (For Eg. List.jsx) is importing the styles as follows:
1st import, the .rcss is our local css files where we use the react-css-modules rules
2nd import belongs to the FixedDataTable Component (Third Party)
3rd import is Global css file that uses standard css rules
This works well with react-css-modules but babel-plugin-react-css-modules throws the error because we are importing two anonymous imports.
Is there a workaround or fix for this?
The text was updated successfully, but these errors were encountered: