npmjs.com/package/config, but for client side JavaScript
npm install lofig --save --production
You can also use https://unpkg.com/lofig@latest/dist/lofig.min.js.
import 'lofig' from 'lofig'; // not necessary if using CDN Link
// change config folder
lofig.folder = 'config/default.json';
// check if property exists
await lofig.has('secret');
// return property
await lofig.get('secret');
// NOTE: You can also use callbacks e.g.
lofig.get('secret', res => {
console.log('secret', res);
})
Run npm run dev
to use webpack-dev-server for development purposes.