Reputation: 45
i am setting a key using npm config set produrl 1234. Here how can i access produrl in side my application.
Upvotes: 1
Views: 386
Reputation: 1139
If you want to read data from your package.json:
webpack.config.js:
const Webpack = require('webpack');
const pkg = require('./package.json')
module.exports = {
...
plugins: [
new Webpack.DefinePlugin({
'process.env': {
PROD_URL: JSON.stringify(pkg.produrl),
},
})
]
}
in your application:
console.log(process.env.PROD_URL)
Upvotes: 2