Last active
March 8, 2018 12:46
-
-
Save yamsellem/6c0a6550588b5b32add7bb5341585fb6 to your computer and use it in GitHub Desktop.
Environment variables
This file contains hidden or 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
var webpack = require('webpack'); | |
var path = require('path'); | |
var LiveReloadPlugin = require('webpack-livereload-plugin'); | |
var BUILD_DIR = path.resolve(__dirname, 'assets/built'); | |
var APP_DIR = path.resolve(__dirname, 'assets/js'); | |
let variables = {}; | |
if (process.env.NODE_ENV === 'production') { | |
variables = { // could be a file | |
stripe: { | |
key: 'pk_live_...' | |
} | |
}; | |
} else { | |
variables = { | |
stripe: { // could be a file | |
key: 'pk_test_...' | |
} | |
}; | |
} | |
var config = { | |
entry: APP_DIR + '/app.jsx', | |
output: { | |
path: BUILD_DIR, | |
filename: '[name].js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.jsx?/, | |
include: APP_DIR, | |
loader: 'babel-loader' | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({'process.env': JSON.stringify(variables)}) | |
] | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment