A Babel plugin that replaces identifier references with literal values during compilation. Version 1.3.1 is the latest stable release. It supports simple literal replacements (strings, booleans) as well as complex expressions via AST nodes. The plugin is commonly used for compile-time constants like __DEV__ or __VERSION__. Compared to alternatives like babel-plugin-replace-identifiers, this one replaces identifiers with literal values, not other identifiers. Low maintenance and simple API, suitable for projects using Babel 6/7.
npm install babel-plugin-inline-replace-variablesVerified import paths — ran on the pinned version, not inferred.
Replace __SERVER__ with true and __VERSION__ with a string literal using Babel plugin configuration.
npm uninstall babel-plugin-inline-replace-varibles && npm install babel-plugin-inline-replace-variables
Use babel-plugin-replace-identifiers for identifier replacement.
Use { type: 'node', replacement: /* AST node */ } for expression replacements.Ensure @babel/core is installed as a dev dependency and that the plugin is compatible (tested with Babel 7+).
Install the correct package: npm install babel-plugin-inline-replace-variables --save-dev
Add the plugin to .babelrc with the replacement value for __SERVER__.
Use format: { '__KEY__': { type: 'node', replacement: someASTNode } }