Skip to content

Instantly share code, notes, and snippets.

@zacck-zz
Created November 17, 2016 14:50
Show Gist options
  • Select an option

  • Save zacck-zz/d9947e06d048f0aab54e1fb3ff4e7cf0 to your computer and use it in GitHub Desktop.

Select an option

Save zacck-zz/d9947e06d048f0aab54e1fb3ff4e7cf0 to your computer and use it in GitHub Desktop.
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const nodeEnv = process.env.NODE_ENV || 'development';
const isProd = nodeEnv === 'production';
module.exports = {
devtool: process.env.NODE_ENV === 'production' ? undefined : 'cheap-module-eval-source-map',
context: path.join(__dirname, '/app'),
entry: {
js: './app.jsx',
vendor: ['react']
},
output: {
path: path.join(__dirname, '/public'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader:[
'babel-loader'
],
options: { //parse the files through react
presets: ['react', 'es2015', 'stage-0']
},
},
],
},
resolve: {
extensions: [".js", ".jsx"],
modules : [
path.resolve('./app'),
'node_modules'
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.bundle.js'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
API_KEY: JSON.stringify(process.env.API_KEY),
AUTH_DOMAIN: JSON.stringify(process.env.AUTH_DOMAIN),
DATABASE_URL: JSON.stringify(process.env.DATABASE_URL),
STORAGE_BUCKET: JSON.stringify(process.env.STORAGE_BUCKET)
}
})
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment