Created
November 21, 2016 06:44
-
-
Save zacck-zz/aa3e344f21107b91164197dbc7026d75 to your computer and use it in GitHub Desktop.
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 webpack = require('webpack'); | |
var path = require('path'); | |
var envFile = require('node-env-file'); | |
//enviroment variable | |
process.env.NODE_ENV = process.env.NODE_ENV || 'development'; | |
//load env file using process.env | |
try { | |
envFile(path.join(__dirname, 'config/'+process.env.NODE_ENV + '.env')); | |
} catch(e) { | |
} | |
module.exports = { | |
//find this file and start from there | |
context: path.join(__dirname, './app'), | |
entry: { | |
js: 'app.jsx', | |
vendor: ['react'] | |
}, | |
externals: { | |
jquery: 'jQuery' | |
}, | |
plugins: [ | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'vendor', | |
minChunks: Infinity, | |
filename: 'public/vendor.bundle.js' | |
}), | |
new webpack.ProvidePlugin({ | |
'$':'jquery', | |
'jQuery':'jquery' | |
}), | |
new webpack.optimize.UglifyJsPlugin({ //Strip warnings to make bundle smaller | |
compress: { | |
warnings: false | |
}, | |
outpu: { | |
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) | |
} | |
}), | |
new webpack.LoaderOptionsPlugin({ | |
options: { | |
sassLoader: { | |
includePaths: [ | |
path.resolve(__dirname, './node_modules/foundation-sites/scss') | |
] | |
} | |
} | |
}) | |
], | |
output: { | |
path: __dirname, | |
filename: './public/bundle.js' | |
}, | |
resolve: { | |
//where all this needs to happen | |
extensions: ['*', '.js', '.jsx'], | |
modules: [ | |
path.resolve('./app'), | |
'node_modules' | |
] | |
}, | |
module: { | |
loaders: [ | |
{ | |
//name of loader | |
loader: 'babel-loader', | |
query: { //parse the files through react | |
presets: ['react', 'es2015', 'stage-0'] | |
}, | |
test: /\.jsx?$/, //regex for .jsx extension | |
exclude: /(node_modules|bower_components)/ //set up folders to be ignored | |
} | |
] | |
}, | |
devtool: process.env.NODE_ENV === 'production' ? undefined : 'cheap-module-eval-source-map' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment