Change manifest path dynamically (both rails and npm package) #467
-
Hi, is there any way to change the manifest.json path dynamically (based on branch name and Rails.env)? ::BRANCH_NAME = `git rev-parse --abbrev-ref HEAD | sed 's/\//_/g'`.chomp.parameterize
class Shakapacker::Configuration
# old_public_output_path = instance_method(:public_output_path)
# define_method(:public_output_path) do
# public_path.join(fetch(:public_output_path), File.read(Rails.root.join(".asset-version")).strip) + "/"
# end
old_public_manifest_path = instance_method(:public_manifest_path)
define_method(:public_manifest_path) do
# puts "Running node with " + ENV["NODE_ENV"].to_s
@webpack_config_public_manifest_path ||= Rails.root.join("config", "asset-manifests", Rails.env, ::BRANCH_NAME, "shakapacker-manifest.json")
end
old_manifest_path = instance_method(:manifest_path)
define_method(:manifest_path) do
# puts "Running node with " + ENV["NODE_ENV"].to_s
@webpack_config_manifest_path ||= Rails.root.join("config", "asset-manifests", Rails.env, ::BRANCH_NAME, "shakapacker-manifest.json")
end
end Is there any better way? Since only the config-yml is loaded, but there is no other way I saw? afaik? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
By default, you can set manifest path per environment in the shakapacker/lib/install/config/shakapacker.yml Lines 29 to 30 in f902e18 If you want to amend the output path for NPM package further, you would have to play around with the webpack config, example below how to amend the manifest output path:
|
Beta Was this translation helpful? Give feedback.
By default, you can set manifest path per environment in the
shakapacker.yml
shakapacker/lib/install/config/shakapacker.yml
Lines 29 to 30 in f902e18
If you want to amend the output path for NPM package further, you would have to play around with the webpack config, example below how to amend the manifest output path: