2016-08-11 03:42:35 +00:00
|
|
|
const webpack = require('webpack')
|
|
|
|
|
|
|
|
const NODE_ENV = process.env.NODE_ENV || 'development'
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
"process.env.NODE_ENV": `"${NODE_ENV}"`
|
|
|
|
})
|
|
|
|
]
|
|
|
|
if (NODE_ENV === 'production') {
|
2016-09-25 13:53:40 +00:00
|
|
|
plugins.push(new webpack.optimize.DedupePlugin())
|
2016-08-11 03:42:35 +00:00
|
|
|
plugins.push(new webpack.optimize.UglifyJsPlugin({
|
|
|
|
compress: { warnings: false }
|
|
|
|
}))
|
2016-10-03 00:32:37 +00:00
|
|
|
} else {
|
|
|
|
// enable this to test for circular dependencies
|
|
|
|
// const CircularDependencyPlugin = require('circular-dependency-plugin')
|
|
|
|
// plugins.push(new CircularDependencyPlugin({
|
|
|
|
// exclude: /^node_modules\//,
|
|
|
|
// failOnError: true
|
|
|
|
// }))
|
2016-08-11 03:42:35 +00:00
|
|
|
}
|
2016-07-31 18:51:06 +00:00
|
|
|
|
2016-10-01 02:49:03 +00:00
|
|
|
const devtool = NODE_ENV === 'production' ? undefined : 'cheap-module-eval-source-map'
|
|
|
|
|
2016-07-31 18:51:06 +00:00
|
|
|
const config = module.exports = {
|
|
|
|
context: __dirname,
|
2016-08-11 03:42:35 +00:00
|
|
|
plugins,
|
2016-10-01 02:49:03 +00:00
|
|
|
devtool,
|
2016-07-31 18:51:06 +00:00
|
|
|
module: {
|
2016-10-07 09:23:11 +00:00
|
|
|
preLoaders: [
|
|
|
|
{ test: /\.json$/, loader: 'json' }
|
|
|
|
],
|
2016-07-31 18:51:06 +00:00
|
|
|
loaders: [
|
|
|
|
{
|
2016-08-01 19:59:53 +00:00
|
|
|
test: /\.(js|jsx)?$/,
|
2016-07-31 18:51:06 +00:00
|
|
|
exclude: /node_modules/,
|
2016-10-03 00:32:37 +00:00
|
|
|
loader: 'babel-loader?cacheDirectory&retainLines=true'
|
2016-07-31 18:51:06 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
entry: {
|
2016-08-03 14:37:02 +00:00
|
|
|
'metamaps.bundle': './frontend/src/index.js'
|
2016-07-31 18:51:06 +00:00
|
|
|
},
|
|
|
|
output: {
|
2016-08-03 14:37:02 +00:00
|
|
|
path: './app/assets/javascripts/webpacked',
|
2016-10-01 04:32:40 +00:00
|
|
|
filename: '[name].js',
|
|
|
|
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
|
2016-07-31 18:51:06 +00:00
|
|
|
}
|
|
|
|
}
|