Skip to content

Issue with directory structure #2451

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
stochastic-thread opened this issue Feb 9, 2020 · 2 comments
Closed

Issue with directory structure #2451

stochastic-thread opened this issue Feb 9, 2020 · 2 comments

Comments

@stochastic-thread
Copy link

I want to be able to leverage webpack(er) in my Rails 6 projects. One thing I find really annoying however, is that in many tutorials and explanations on how to effectively import libraries like bootstrap, etc., one step is to create a /stylesheets or /css subdir under /javascripts under /app. I think this is ugly and does not lend itself to a project that is built for the longer term. Can someone here help me understand what is needed to be able to keep my stylesheets under assets/stylesheets since that seems more sane than putting stylesheets under the javascripts folder?

I'm sorry if this is "not relevant" for this project, but for future posterity I think this would be useful since similar comments have been posted on basically every Rails 6 webpacker tutorial that I've found so far.

Thanks, appreciate your time.

@jakeNiemiec
Copy link
Member

You can find other explanations on here, but the short answer is this:

Instead of compass or ruby compiling your sass, you now have nodejs compiling it. This allows you to compile styles, streaming them into the browser without reloading. My favorite part is that each style can be traced back to the exact line in the sass file (all within the browser):

image

Can someone here help me understand what is needed to be able to keep my stylesheets under assets/stylesheets since that seems more sane than putting stylesheets under the javascripts folder?

How do you include your styles currently? You can aways relatively include styles from your JS like:

// app/javascript/packs/application.js
import './../../assets/stylesheets/myStyle.scss'

@jakeNiemiec
Copy link
Member

Related: #1833

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

No branches or pull requests

2 participants