class WebpackManifestPlugin::Configuration
Gem Configurations¶ ↑
Example:¶ ↑
# put in config/initializers/webpack_manifest_plugin.rb WebpackManifestPlugin.configure do |c| c.webpack_cmd = 'node node_modules/webpack/bin/webpack' c.cache_manifest = Rails.env.production? ? true : false c.logger = Rails.logger end
Attributes
app_root[RW]
App root. Set to Rails.root in engine initializer. Otherwise empty string.
cache_manifest[RW]
Boolean. Cache manifest.json on application loads. Otherwise, it caches per request. Defaults to false.
logger[RW]
Defaults to Logger.new(STDOUT)
manifest_path[RW]
String. Relative path to app root to manifest.json file. Defaults to 'public/assets/manifest.json'.
webpack_cmd[RW]
String. Command to execute webpack. Defaults to 'webpack'. Used in rake tasks.
Public Class Methods
new()
click to toggle source
# File lib/webpack_manifest_plugin/configuration.rb, line 32 def initialize set_defaults end
Public Instance Methods
load_manifest()
click to toggle source
# File lib/webpack_manifest_plugin/configuration.rb, line 44 def load_manifest file_path = File.join(@app_root, @manifest_path) Oj.load(File.read(file_path)) end
manifest()
click to toggle source
Hash. If cache_manifest
== true, it caches the manifest here the first time its fetched. Otherwise, returns nil.
# File lib/webpack_manifest_plugin/configuration.rb, line 38 def manifest @manifest ||= begin @cache_manifest ? load_manifest : nil end end
Protected Instance Methods
set_defaults()
click to toggle source
# File lib/webpack_manifest_plugin/configuration.rb, line 51 def set_defaults @app_root = '' @webpack_cmd = 'webpack' @manifest_path = 'public/assets/manifest.json' @cache_manifest = false @logger = Logger.new(STDOUT) @manifest = nil end