Created
January 24, 2017 16:44
-
-
Save krambertech/44e00d16086dd21c8615a7e4c5ab5ef4 to your computer and use it in GitHub Desktop.
React Webpack env example
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
{ | |
"name": "webpack-demo", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "webpack", | |
"build": "cross-env NODE_ENV=production webpack -p" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"emoji-green-heart": "^1.2.1" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.17.0", | |
"babel-loader": "^6.2.5", | |
"babel-preset-es2015": "^6.16.0", | |
"cross-env": "^3.1.1", | |
"webpack": "^2.1.0-beta.25" | |
} | |
} |
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 webpack = require('webpack'); | |
const NODE_ENV = process.env.NODE_ENV || 'development'; | |
module.exports = { | |
entry: './main.js', | |
output: { | |
path: './build', | |
filename: 'bundle.js' | |
}, | |
watch: NODE_ENV === 'development', | |
devtool: NODE_ENV === 'development' && 'eval-source-map', | |
module: { | |
loaders: [{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader' | |
}] | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify(NODE_ENV) | |
} | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment