Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
my rails helper for webpack dev server, and compiled into public
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
You can’t perform that action at this time.