Last active
April 6, 2017 10:27
-
-
Save mistakster/0b78f3c022901e78c39806c3157ce0c8 to your computer and use it in GitHub Desktop.
The platform independent way to provide environment variables inside “npm scripts” section
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
const ENV = process.env.NODE_ENV; |
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
{ | |
"name": "run-scripts", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "webpack", | |
"build:release": "cross-env NODE_ENV=production webpack", | |
"build:debug": "cross-env NODE_ENV=development webpack" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"cross-env": "^4.0.0", | |
"webpack": "^2.3.3" | |
} | |
} |
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
const webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
main: './index.js' | |
}, | |
output: { | |
path: __dirname + '/public', | |
filename: '[name].js' | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment