2016-01-04 22 views
0

我試圖使用broccoli-config-replace失敗。我想這樣做的是通過執行broccoli servebroccoli-config-replace不能使用給定的配置

我Brocfile.js有趣的部分,我index.html替換的佔位符,看看它在瀏覽器是這一個:

var index_html = new ConfigReplace(app, './', { 
    // A list of files to parse: 
    files: [ 
     'index.html', 
    ], 
    configPath: 'replacements.json', 
    outputPath: 'production/', 
    patterns: [{ 
     match: /\{\{SRC_REQUIRE\}\}/g, 
     replacement: function(config) { return config.SRC_REQUIRE; } 
    }] 
}); 

module.exports = index_html; 

但是當我運行broccoli serve我得到的是這樣的警告並沒有被出現在我的瀏覽器指向localhost:4200

$ broccoli serve 

Serving on http://localhost:4200 

Warning: failed to stat tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/tmp/config_replace-input_base_path-5qF5n457.tmp/1/node_modules/broccoli-babel-transpiler/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/README.md 
Segmentation fault: 11 

漂亮段錯誤吧?我想我寫的不是那麼好,但是文檔非常缺乏。任何人都可以爲我提出正確的配置來完成這個簡單的任務嗎?謝謝

回答

0

我已經想出瞭如何得到我想要的,但我認爲插件仍然需要一些發展。這是正確的配置:

var index_html = new ConfigReplace(appHtml, 'conf', { 
    // A list of files to parse: 
    files: [ 
     '/production/index.html' 
    ], 
    configPath: 'replacements.json', 
    patterns: [{ 
     match: /\{\{SRC_REQUIRE\}\}/g, 
     replacement: function(config) { return config.SRC_REQUIRE; } 
    }] 
}); 

一些事實,我注意到:

  • 配置節點必須是一個目錄。 Root是不允許的,所以我必須將我的replacements.json放在子文件夾中(/conf
  • outputPath選項似乎不被考慮。我省略了它,並在之前使用了pickFile以創建一個具有我想要的正確結構的樹。然後我通過樹ConfigReplace(你在我粘貼上面的配置中看到的appHtml
  • 缺乏文檔是愉快採用花椰菜的壞朋友。雖然我有信心。