You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Webpack plugin designed to lets us interpolate custom predefined variables into assets.
Builtin variables
%GIT_DESCRIBE%: result of git describe --tags
%GIT_REV%: result of git rev-parse --short HEAD
%GIT_VERSION%: %GIT_DESCRIBE% or %GIT_REV%
%packageJson.[data.path.in.package.json]%: any data in package.json
Install
yarn add @c4605/interpolate-webpack-plugin -D
# or
npm install @c4605/interpolate-webpack-plugin --save-dev
Usage
import{InterpolateWebpackPlugin,DefaultReplacer}from'interpolate-webpack-plugin'exportdefault{// ... webpack configsplugins: [// Use with default replacernewInterpolateWebpackPlugin(newDefaultReplacer({ options }),),// Or use custom replacernewInterpolateWebpackPlugin({replacer: (filename,source)=>newPrefixSource(prefix: '/* prefix */',source,)}),],}
Options structure can find in src/index.ts#InterpolateWebpackPluginOptions.
The default replacer will not modify binary files (checked by isBinaryFile) and sourcemap files.
If you want to use the builtin variables, you can to this: