Sha256: 82d539514827d741360ab8bf0e6cbd8a3e75fb7c7fcd2ea3b2226c0242f8ecc7
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
module WebpackManifestPlugin # View helpers available in the application. module ViewHelpers # Webpack manages asset paths in your CSS and Javascript files but not in your Rails # templates. The npm webpack-manifest-plugin generates a json file (see example # below). 'webpack_manifest_path' uses this file to inject the correct path. # # { # "common.css": "/assets/stylesheets/common.css", # "common.js": "/assets/javascripts/common.js", # "fonts/fontawesome-webfont.ttf?v=4.6.3": "/assets/fonts/fontawesome-webfont.ttf", # "images/panel_bg.png": "/assets/images/panel_bg.png" # } # # Specify an asset hash key like so: # # <img src="<%= webpack_manifest_path("images/panel_bg.png") %>" width="40px"></img> # <script src="<%= webpack_manifest_path("common.js") %>"></script> # <link href="<%= webpack_manifest_path("common.css") %>" rel="stylesheet" type="text/css"> # # Returns asset path if key exists, otherwise returns the key itself. If an exception occurs, # it logs the error and returns an empty string. def webpack_manifest_path(key) webpack_manifest_configs[key] || key rescue StandardError => ex WebpackManifestPlugin.logger.warn "Error parsing webpack manifest JSON. #{ex.message}" '' end # Manifest configs as a hash. def webpack_manifest_configs c = WebpackManifestPlugin.configuration c.manifest || (@webpack_manifest_configs ||= c.load_manifest) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
webpack_manifest_plugin-0.1.1 | lib/webpack_manifest_plugin/view_helpers.rb |
webpack_manifest_plugin-0.1.0 | lib/webpack_manifest_plugin/view_helpers.rb |