javascriptbroccolijs

broccoli-config-replace does not work with the configuration given


I'm trying to use broccoli-config-replace unsuccessfully. What I would like to do is replacing a placeholder in my index.html and see it in the browser by executing broccoli serve

The interesting part of my Brocfile.js is this one:

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;

but when I run broccoli serve what I get is this warning and nothing appears by pointing my browser to 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

nice segfault huh? I guess what I've written is not that OK, but the documentation is very lacking. Can anybody suggest me the right configuration to accomplish this simple task? Thank you


Solution

  • I've figured out how to get what I want, but I think the plugin still needs some development. Here is the right configuration:

    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; }
        }]
    });
    

    Some facts I've noted: