@staticdeploy/app-config
v2.0.2
Published
Configuration for static apps
Keywords
Readme
app-config
A tool for generating configuration files for static apps.
Install
yarn add @staticdeploy/app-configQuickstart
add the following
<script>to yourpublic/index.html:<script id="app-config" src="http://localhost:3456/app-config.js"></script>access the config variable in your code:
console.log(window.APP_CONFIG.MY_VAR);
Then:
In development
define configuration in the
.envfile:APP_CONFIG_MY_VAR=my_valstart the development server with
$(npm bin)/dev-config-server
In production
build your app and get the path of the app's
index.html(for example, for apps built with create-react-app the path isbuild/index.html)defining configuration via environment variables:
export APP_CONFIG_MY_VAR=my_valinject the configuration into the index file by running:
$(npm bin)/inject-config --file path/to/index.html
