Created
March 18, 2017 18:49
-
-
Save thejmazz/477d0a59c630540037e88b541cb11838 to your computer and use it in GitHub Desktop.
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
'use strict' | |
const path = require('path') | |
const webpack = require('webpack') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const CopyWebpackPlugin = require('copy-webpack-plugin') | |
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') | |
const whsAliases = require('whs/tools/alias.js') | |
const isProd = process.env.NODE_ENV === 'production' | |
const basePlugins = [ | |
new CopyWebpackPlugin([{ | |
from: 'public', | |
to: '.' | |
}], { | |
ignore: [ '.DS_Store' ] | |
}), | |
new HtmlWebpackPlugin({ | |
title: 'Binary Capital', | |
template: './src/index.html' | |
}), | |
new BundleAnalyzerPlugin() | |
] | |
const prodPlugins = [ | |
new webpack.LoaderOptionsPlugin({ | |
minimize: true | |
}), | |
new webpack.optimize.UglifyJsPlugin() | |
] | |
const plugins = isProd ? basePlugins.concat(prodPlugins) : basePlugins | |
const config = { | |
entry: './src/app.js', | |
devtool: isProd ? 'source-map' : 'eval-source-map', | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: 'bundle.js', | |
publicPath: '/' | |
}, | |
module: { | |
rules: [{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /(node_modules\/(?!whs)|bower_components)/ | |
}, { | |
test: /\.glsl$/, | |
loaders: [ 'raw-loader', 'glslify-loader' ], | |
exclude: /node_modules/ | |
}] | |
}, | |
resolve: { | |
alias: whsAliases | |
}, | |
plugins, | |
devServer: { | |
contentBase: path.resolve(__dirname, 'dist'), | |
stats: { chunks: true } | |
}, | |
}; | |
module.exports = config |
Author
thejmazz
commented
Mar 18, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment