Created
January 17, 2016 00:51
-
-
Save mbriggs/c489204a251e3914b384 to your computer and use it in GitHub Desktop.
my rails helper for webpack dev server, and compiled into public
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def include_js(file) | |
@_js_includes ||= {} | |
@_js_includes[file] ||= begin | |
manifest_path = Rails.root.join('public', 'assets', 'manifest.json') | |
if File.exist?(manifest_path) | |
manifest = JSON.parse(File.read(manifest_path)) | |
path = "/assets/#{manifest[file]}" | |
else | |
path = "http://127.0.0.1:8080/#{file}" | |
end | |
%(<script type="text/javascript" src="#{path}"></script>).html_safe | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment