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

Importing external CSS goes kaboom #103

Closed
tristanoneil opened this issue Jul 22, 2016 · 9 comments
Closed

Importing external CSS goes kaboom #103

tristanoneil opened this issue Jul 22, 2016 · 9 comments

Comments

@tristanoneil
Copy link

When I installed hack and then tried importing it I get the following error. 💥💥💥

Error in ./~/hack/dist/hack.css
Module parse failed: /Users/tristanoneil/src/saute/node_modules/hack/dist/hack.css Unexpected token (1:4)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:4)
 @ ./src/index.js 11:0-15

Feel free to close if this just isn't how create-react-app is intended to be used but I could see others being bit by this as well so hence the issue.

@glennreyes
Copy link
Contributor

glennreyes commented Jul 22, 2016

The default config resolves CSS files only located in your src folder:
https://github.com/facebookincubator/create-react-app/blob/master/config/webpack.config.dev.js#L70

You can solve this by ejecting the config and removing the line or put another loader for external CSS.

@tristanoneil
Copy link
Author

@glennreyes sure that's a fine work around but it seems like it'd be nice to resolve CSS from node_modules as well. ¯_(ツ)_/¯

@keyz
Copy link
Contributor

keyz commented Jul 22, 2016

@glennreyes I think we can just remove that include line for .css. The reason we need that for .js is we don't want babel to transform stuff under node_modules, but for CSS files they should be processed by webpack anyway so it should be fine. Do you want to send a PR?

also cc @gaearon to double check. :)

@glennreyes
Copy link
Contributor

@keyanzhang Sure 😉

@keyz
Copy link
Contributor

keyz commented Jul 22, 2016

Thanks @glennreyes!

@tristanoneil
Copy link
Author

@glennreyes @keyanzhang 🎉 Yey! Thanks!

@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2016

Should be fixed in 0.2.0 alpha. Please help us test it! #190

@tristanoneil
Copy link
Author

Tested in 0.2.0 alpha and this worked as expected. 🌞

@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2016

FWIW alpha is now stable so newly created projects will just work with this, and old projects can be updated to "react-scripts": "0.2.0".

@lock lock bot locked and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants