Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.29 KB

replace.md

File metadata and controls

46 lines (31 loc) · 1.29 KB

Replace Extension

Task Definitions: None
Template Definitions: 'replace'
Batcher Defintions: None

Performs string and regular expression replacements.

Replace Template

Template Options

  • 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.

Example

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']
]

Ejection

When ejecting the template, the complete replacement implementation source is provided as the Node.js task, without any dependencies.

Roadmap

  • 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.