由于事实上,我发现到目前为止,我已经创建了所有的符号连接钢轨发动机的余烬引擎目录到消费烬发动机的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