2018-03-31 06:17:21 +00:00
|
|
|
const webpack = require('webpack')
|
2018-03-28 22:11:40 +00:00
|
|
|
/**
|
|
|
|
* After the next require you can use process.env to get your secrets
|
|
|
|
*/
|
2018-05-05 05:14:59 +00:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
require('now-env')
|
|
|
|
}
|
2018-03-28 22:11:40 +00:00
|
|
|
|
|
|
|
console.log({
|
|
|
|
SECRET: process.env.SECRET,
|
|
|
|
ANOTHER_SECRET: process.env.ANOTHER_SECRET,
|
|
|
|
SECRET_FAIL: process.env.SECRET_FAIL
|
|
|
|
})
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If some of the envs are public, like a google maps key, but you still
|
|
|
|
* want to keep them secret from the repo, the following code will allow you
|
|
|
|
* to share some variables with the client, configured at compile time.
|
|
|
|
*/
|
|
|
|
module.exports = {
|
|
|
|
webpack: config => {
|
2018-03-31 06:17:21 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.SECRET': JSON.stringify(process.env.SECRET)
|
|
|
|
})
|
|
|
|
// Same as above
|
|
|
|
// new webpack.EnvironmentPlugin(['SECRET'])
|
|
|
|
)
|
2018-03-28 22:11:40 +00:00
|
|
|
return config
|
|
|
|
}
|
|
|
|
}
|