Skip to content
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

Global styles? #91

Closed
oshalygin opened this issue May 19, 2017 · 5 comments
Closed

Global styles? #91

oshalygin opened this issue May 19, 2017 · 5 comments
Labels

Comments

@oshalygin
Copy link

I tried this all sorts of ways but this doesn't work like the react-css-modules project which allows you to do the following:

import '!style!css!../node_modules/bootstrap/dist/css/bootstrap.min.css';

how do you import global styles with this project?

@gajus gajus added the question label May 19, 2017
@ramasilveyra
Copy link

A pattern for deal with css modules files and global css files is to use the .module.css file name convention, more info here webpack-contrib/css-loader#308.
If you adopt that you could use the exclude option with a regex that matches files that don't end in .module.css (/.*[^.module.css]$/ probably, not tested).

@oshalygin
Copy link
Author

Solid advice, to get this working with a similar approach, when importing the global style, use the minified version. so .*[^.min.css]

@oshalygin
Copy link
Author

Closing this out as there's a clear solution in mind.

@mohandere
Copy link

Hi @oshalygin
I am trying the same with create-react-app by ejecting app.

import styles from './App.css';
import 'bootstrap/dist/css/bootstrap.css';

Still i am unable to make bootstrap css work. Can you guys please provide an sample codes ?

Thank you so much for this feature.

@jasonk
Copy link

jasonk commented Mar 24, 2019

I realize I'm responding to a really old ticket, but I found my way here from Google while trying to figure out exactly how the exclude option works. So I thought I would provide some info for any future travellers who stumble across this.

If you are having problems with this and you used one of the regexps that were posted in the issue:

  • .*[^.module.css]$ does not mean "exclude files that don't end with .module.css", it means "exclude files that do not end with ., m, o, d, u, l, e, c, or s"
  • .*[^.min.css] does not mean "exclude files that don't end with .min.css", it means "exclude files that do not include ., m, i, n, c, or s"

For the first case, you can use: ^(?!.*[.]module[.]css$).*$ or the overly verbose [^.][^m][^o][^d][^e][^.][^c][^s][^s]$.

For the second case I would suggest you probably want to exclude files that end with .min.css rather than excluding them if they aren't minified. In that case . you can just use exclude : "[.]min[.]css$".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants