Task Definitions: None
Template Definitions: 'replace'
Batcher Defintions: None
Performs string and regular expression replacements.
replacements
(List[from: String, to: String]): List of replacements to apply.throw-unmatched
(Boolean, default:false
): Whether to throw if any of the replacements aren't found.
Regular expression replacements are supported when the from string is a regex.
Replacements are applied one after the other in order.
chompfile.toml
version = 0.1
extensions = ['[email protected]:replace']
[[task]]
target = 'dist/app.js'
dep = 'lib/app.js'
template = 'replace'
[task.template-options]
replacements = [
['ENV', '"production"'],
['/version-(\d+)/g', 'version-production-$1']
]
When ejecting the template, the complete replacement implementation source is provided as the Node.js task, without any dependencies.
- It would be beneficial to integrate environment variable replacements into the plugin replacements.
- It could be nice to integrate a configuration system that drives such variables, where variable changes could be tracked. For example to get a replacement from a JSON configuration file, etc.