Last active
May 15, 2017 07:40
-
-
Save saurabh2590/c4450924ca21f511230ea638ee86f6f3 to your computer and use it in GitHub Desktop.
Example for webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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