Skip to content

Instantly share code, notes, and snippets.

@saurabh2590
Last active May 15, 2017 07:40
Show Gist options
  • Save saurabh2590/c4450924ca21f511230ea638ee86f6f3 to your computer and use it in GitHub Desktop.
Save saurabh2590/c4450924ca21f511230ea638ee86f6f3 to your computer and use it in GitHub Desktop.
Example for webpack
const settings = (mode === 'production') ? JSON.stringify(require('./src/config/settings.prod.json')) : JSON.stringify(require('./src/config/settings.dev.json'));
module.exports = {
context: path.resolve('./src'),
entry: {
vendor: ['react', 'pouchdb', 'redux', 'whatwg-fetch'],
demo_app: './init.tsx'
},
output: {
path: path.resolve('./dist'),
filename: 'static/js/[name].bundle.js'
},
externals: {
settings: settings
},
.....
That's how our settings.dev.json looks like.
{
"remoteCouchUrl": "http://localhost:5984/",
"apiBaseUrl": "http://localhost:3000"
}
and in settings.prod.json you can production values.
This is how we import them.
import * as settings from 'settings'; (It's typescript syntax as we are using react with typescript.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment