Created
June 22, 2016 09:31
-
-
Save diem1/c752080db8ea2a1b59cc3822fbce9de1 to your computer and use it in GitHub Desktop.
Webpack config to support environment variables in JS app
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 domain = process.env.DOMAIN || null; | |
console.log(domain); |
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 ExtractTextPlugin = require("extract-text-webpack-plugin"), | |
webpack = require('webpack'); | |
module.exports = { | |
node: { | |
fs: "empty" | |
}, | |
entry: './index', | |
output: { | |
path: __dirname, | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader') | |
}, | |
{ | |
test: /.js?$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
query: { | |
presets: ['es2015', 'react'] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('bundle.css'), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'DOMAIN': JSON.stringify(process.env.DOMAIN) | |
} | |
}) | |
], | |
devServer: { | |
port: 8080, | |
historyApiFallback: true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment