From 5db27a3ce4b54a33270320e25b9110f47358b327 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Tue, 8 Feb 2022 18:36:51 +0100 Subject: [PATCH] docs: add note about replace preprocessor to replace all occurences (#478) --- README.md | 2 +- docs/preprocessing.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a87831d0..7ccff29a 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ In example, to replace inject the value of `process.env.NODE_ENV`: ```js autoPreprocess({ - replace: [['process.env.NODE_ENV', JSON.stringify(process.env.NODE_ENV)]], + replace: [[/process\.env\.NODE_ENV/g, JSON.stringify(process.env.NODE_ENV)]], }); ``` diff --git a/docs/preprocessing.md b/docs/preprocessing.md index 6f88cca9..1f4d61cc 100644 --- a/docs/preprocessing.md +++ b/docs/preprocessing.md @@ -484,3 +484,5 @@ And the result, with a `NODE_ENV = 'production'` would be:

Production environment!

{/if} ``` + +> Note: a string can be used instead of a `RegExp`, but only a single occurence of it will change, as per the default behavior of `String.prototype.replace`.