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

asset_pack_path should resolve other than stylesheets in dev mode #1202

Closed
tai2 opened this issue Jan 22, 2018 · 4 comments
Closed

asset_pack_path should resolve other than stylesheets in dev mode #1202

tai2 opened this issue Jan 22, 2018 · 4 comments
Labels

Comments

@tai2
Copy link
Contributor

tai2 commented Jan 22, 2018

def asset_pack_path(name, **options)
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?
asset_path(Webpacker.manifest.lookup!(name), **options)
end
end

As long as I see above code, asset_pack_path returns empty in HMR mode.

<%= asset_pack_path 'images/calendar.png' %>

So, this yields nothing.

I think assets other than stylesheets(.png, .svg, etc) should be put by asset_pack_path even in HMR mode.

@gauravtiwari
Copy link
Member

@tai2 Ahh yes this is a bug. Could you please make a PR?

@tai2
Copy link
Contributor Author

tai2 commented Jan 22, 2018

@gauravtiwari I'll try it. Wait a minute.

@gauravtiwari
Copy link
Member

thanks

@tai2
Copy link
Contributor Author

tai2 commented Jan 22, 2018

@gauravtiwari

With target file name given, what we can do is checking the file name extension.
But what extensions are those of stylesheets?

The simplest solution is hard-coding the stylesheet extensions such as .css, .scss, .sass
or .less in the code then matching these against name argument. In this case, if users register a new file extension for stylesheets, these files will be treated as non-stylesheet one by webpacker.

More flexible solution is adding stylesheet_extensions field to webpacker.yml and using it in file type detection.

I think the later is preferable one but stylesheet extensions occur twice in a file. It's a bit redundant.
Do you have any ideas about how to solve this problem?

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

2 participants