Created
June 6, 2017 13:08
-
-
Save MarcelRobitaille/8daf23e25ce62f6787e902077d6fd75e 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
const path = require('path') | |
const process = require('process') | |
const webpack = require('webpack') | |
const CompressionPlugin = require('compression-webpack-plugin') | |
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | |
const Dashboard = require('webpack-dashboard') | |
const DashboardPlugin = require('webpack-dashboard/plugin') | |
let dashboard | |
const debug = process.env.NODE_ENV === 'development' | |
const plugins = [ | |
new webpack.optimize.CommonsChunkPlugin({ name: 'common', filename: debug ? 'common.js' : 'common-[chunkhash].js' }), | |
] | |
if (!debug) plugins.push(...[ | |
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }), | |
new CompressionPlugin(), | |
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | |
]) | |
if (process.env.WEBPACK_ANALYZE === 'true') { | |
plugins.push(new BundleAnalyzerPlugin()) | |
} | |
if (process.env.WEBPACK_DASHBOARD === 'true') { | |
dashboard = new Dashboard() | |
plugins.push(new DashboardPlugin(dashboard.setData)) | |
} | |
module.exports = { | |
// stats: 'none', | |
stats: { | |
colors: false, | |
hash: false, | |
version: false, | |
timings: false, | |
assets: false, | |
chunks: false, | |
modules: false, | |
reasons: false, | |
children: false, | |
source: false, | |
errors: false, | |
errorDetails: false, | |
warnings: false, | |
publicPath: false, | |
chunkModules: false, | |
moduleTrace: false, | |
}, | |
devtool: debug ? 'source-map' : false, | |
plugins, | |
entry: { | |
'device': [ | |
'./source/js/device/index.js', | |
], | |
'settings': [ | |
'./source/js/settings/index.js', | |
], | |
'schedule': [ | |
'./source/js/schedule/index.js', | |
], | |
'common': [ | |
'regenerator-runtime/runtime', | |
'./node_modules/material-design-lite/material.js', | |
], | |
}, | |
output: { | |
// Set output path to 'public' for debug and 'build' for prod | |
path: path.join(__dirname, debug ? 'public' : 'build', 'js'), | |
// Don't change filename for debug | |
// Cache bust filename for prod | |
filename: debug ? '[name].js' : '[name]-[chunkhash].js', | |
}, | |
module: { | |
rules: [{ | |
test: /\.js$/, | |
exclude: [ | |
path.resolve(__dirname, 'node_modules'), | |
], | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['env'], | |
}, | |
}, | |
}, { | |
test: /\.pug$/, | |
exclude: [ | |
path.resolve(__dirname, 'node_modules'), | |
], | |
use: { | |
loader: 'pug-loader', | |
}, | |
}], | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment