由於事實上,我發現到目前爲止,我已經創建了所有的符號連接鋼軌發動機的餘燼引擎目錄到消費燼發動機的node_modules
在消費Rails應用程序的初始化沒有其他解決辦法:
# Get the node_modules dir
nm_dir = Rails.root.join('frontend', 'node_modules')
# Delete existing symlinks
Dir.new(nm_dir.to_s).each { |entry| FileUtils.rm_rf(entry) if entry =~ /^.+\-frontend$/ }
# MODULES contains an array of the rails engine gem names
MODULES.each do |module_name|
# Each module has a Manifest class, load that
manifest = load_manifest(module_name)
# Get the path to the frontend dir of the rails engine
source = Pathname.new(manifest.method(:setup).source_location[0].split('/lib/')[0]).join('frontend').to_s
# Symlink destination
destination = nm_dir.join("#{module_name}-frontend").to_s
# Symlink it
FileUtils.symlink source, destination, force: true
end
這種方法可能不是很乾淨,但它似乎工作。
同時我發現了'npm link'並重建了上面的代碼片段來使用npm鏈接,而不是手動創建符號鏈接。 https://docs.npmjs.com/cli/link – phortx