Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Is the documentation for adding CSS files from node_modules (using TypeScript) correct? #247

Closed
dccarmo opened this issue Feb 6, 2018 · 4 comments

Comments

@dccarmo
Copy link

dccarmo commented Feb 6, 2018

According to the User Guide, you can import CSS files from node_modules like this:

import 'bootstrap/dist/css/bootstrap.css';

But I can't make that work, and I'm assuming the docs for TypeScript requires a bit more setup sotsc can compile properly. Right now I'm getting this error:

Module not found: Can't resolve 'bulma/bulma.css' in '/Users/.../src'

What is the correct way of making TypeScript and Webpack play along nicely in this case without ejecting?

@ianschmitz
Copy link
Contributor

Can you try using require instead?

require('bootstrap/dist/css/bootstrap.css')

I know i've had issues with images following the create-react-app user guide, but using require works just fine.

@dccarmo
Copy link
Author

dccarmo commented Feb 6, 2018

That worked! But only after I reset the watcher. After that, even import is working.

Weird, but well, it's working now.

Thanks!

@dccarmo dccarmo closed this as completed Feb 6, 2018
@matthewberryman
Copy link

require isn't working for me. What's the 'nice' solution here? I could use webpack although that seems like a lot of work, or manually copying the css over and referencing (but then when I update bootstrap I need to manually copy them back over)

@matthewberryman
Copy link

sorry, my bad, the instructions I was following had a import 'bootstrap/dist/css/bootstrap-theme.css'; and on checking the latest bootstrap I'm using that doesn't exist any more. Removing that line and leaving import 'bootstrap/dist/css/bootstrap.css'; successfully imports that. :)

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

3 participants