Gathering detailed insights and metrics for html-webpack-dynamic-env-plugin
Gathering detailed insights and metrics for html-webpack-dynamic-env-plugin
Gathering detailed insights and metrics for html-webpack-dynamic-env-plugin
Gathering detailed insights and metrics for html-webpack-dynamic-env-plugin
Extension plugin for html-webpack-plugin that allows specifying dynamic environment for static html apps
npm install html-webpack-dynamic-env-plugin
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
19 Commits
1 Branches
1 Contributors
Updated on Aug 05, 2022
Latest Version
0.0.2
Package Id
html-webpack-dynamic-env-plugin@0.0.2
Unpacked Size
17.42 kB
Size
6.11 kB
File Count
25
NPM Version
5.6.0
Node Version
9.4.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
This is an extension plugin for the webpack plugin html-webpack-plugin that allows configure environment variables for static html app after build step and before deployment (e.g. push to cdn or docker run)
This plugin subscribes on html-webpack-plugin hooks and webpack hooks, enhances output html files with default environment variables, plus generates template files for every output html with a script file to replace environment variables.
If you need/want to be able to configure your environment variables after app bundle and you don't want/can't setup heavy server side.
1npm i -D html-webpack-dynamic-env-plugin
Require the plugin in your webpack config:
1var HtmlWebpackDynamicEnvPlugin = require('html-webpack-dynamic-env-plugin');
Add the plugin to your webpack config (remember to add it after html-webpack-plugin):
1plugins: [ 2 new HtmlWebpackPlugin(), 3 new HtmlWebpackDynamicEnvPlugin({ 4 envVars: { 5 YOUR_ENV_VARIABLE: "default-value-here", 6 ANOTHER_ENV_VAR: process.env.SET_DEFAULT_VALUE_FROM_BUILD_ENV || '' 7 } 8 }) 9]
This will generate index.html file from HtmlWebpackPlugin with injected script tag that defines your environment defaults. It should look something like this:
1window.CLIENT_ENV = { YOUR_ENV_VARIABLE: "default-value-here", ANOTHER_ENV_VAR: "" }
Plus you'll have your config-env.sh and index.html.template files generated that you can use to configure your environment again, like this:
1YOUR_ENV_VARIABLE=newvalue ./config-env.sh index.html.template index.html
List of available configuration options:
Name | Type | Default | Description |
---|---|---|---|
envVars | { [key: string]: string | undefined } | `` | Key-value map of environment variables. Values will be used as defaults in generated html output file |
windowKeyName | string | 'CLIENT_ENV' | Property name to be used on window object to store environment variables |
injectEnvVars | (string, string, string) => string | headAppend | Function that injects environment variables into html and template files. takes html, script tag with env and filename as parameters, returns html with injected tag. By default appeands to head tag |
configFileName | string | 'config-env.sh' | File name for the generated configuration script |
configFactoryFunc | string | envs => string | 'shell' | Configuration script factory function. Can be either pre-defined type, e.g. 'shell' or a custom function-factory of the type: takes envVars type in and returns script file content as a string |
templateFileNames | { [key: string]: string } | {} | Key-value map, where: key - file name of generated by html-webpack-plugin html file; value - template file name for this html.For every not specified html filename - template with default pattern-name will be generated. I.e. { "index.html": "index.html.template" } |
You can find examples in Examples folder.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
95 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More