2016-12-15 63 views
1

我們有一個高模塊化的rails5應用程序,它在軌道引擎中分成多個存儲庫並集成爲紅寶石寶石。Ember發動機通過ember-cli-rails引擎通過ember-cli-rails

現在我們想通過使用ember-cli-rails來介紹EmberJS。主導軌應用程序包含frontend目錄中的主要應用程序應用程序,而每個導軌引擎在frontend目錄中包含一個支持引擎(通過ember-engine)。

如何將模塊的餘燼引擎安裝到主要的餘燼引擎中?

回答

0

由於事實上,我發現到目前爲止,我已經創建了所有的符號連接鋼軌發動機的餘燼引擎目錄到消費燼發動機的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 

這種方法可能不是很乾淨,但它似乎工作。

+0

同時我發現了'npm link'並重建了上面的代碼片段來使用npm鏈接,而不是手動創建符號鏈接。 https://docs.npmjs.com/cli/link – phortx