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

Rails: Precompiled assets missing node modules #414

Closed
jonhue opened this issue Dec 4, 2017 · 2 comments
Closed

Rails: Precompiled assets missing node modules #414

jonhue opened this issue Dec 4, 2017 · 2 comments

Comments

@jonhue
Copy link

jonhue commented Dec 4, 2017

I am using yarn with my rails 5.1 app (not webpacker, just the default asset pipeline).

Running a local server in development environment, I experience no issues with my assets.

But as soon as I precompile my assets (the environment doesn't matter) or let Heroku package my assets, all stylesheets (of node modules) I imported from within my application.sass file don't work anymore.

The reason for that behavior is that sass compiles all files into one output file, but because of some reason appears to miss the @import statements, which include node modules and loads these files separately.

So this:

@import "components/index.sass"
@import "node_module/nodemodule.css"

Compiles to this in development:

// content of "components/index.sass"
// content of "node_module/nodemodule.css"

and to this in production:

// content of "components/index.sass"
@import "node_module/nodemodule.css"

while loading node_module/nodemodule.css separately as an asset, but the browser cannot resolve it.

@s0nspark
Copy link

Sounds like you need to add the node_modules folder to your asset load path in the assets.rb initializer:

Rails.application.config.assets.paths << Rails.root.join('node_modules')

@jonhue
Copy link
Author

jonhue commented Jan 10, 2018

@s0nspark

I created a new issue for the problem described here. #417

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

No branches or pull requests

2 participants