我们有一个高度模块化的rails5应用程序,它被分割在rails引擎上,而不是服务器存储库,并集成成红宝石。
现在我们想通过使用EmberJS来介绍ember-cli-rails。主rails应用程序在frontend目录中包含主ember应用程序,而每个rails引擎在frontend目录中包含一个ember引擎(通过ember-engine)。
如何将模块的剩馀引擎安装到主ember引擎中?
发布于 2016-12-16 08:51:19
由于到目前为止我还没有找到其他解决方案,所以我创建了一个初始化器,它将所有rails引擎的fact引擎目录符号链接到消费rails应用程序中的ember引擎的node_modules中:
# 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这种方法可能不太干净,但似乎奏效了。
https://stackoverflow.com/questions/41165548
复制相似问题