metamaps--metamaps/webpack.config.js

61 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-08-11 03:42:35 +00:00
const webpack = require('webpack')
const NODE_ENV = process.env.NODE_ENV || 'development'
2018-03-11 20:24:57 +00:00
const ACTIONCABLE = process.env.ACTIONCABLE
2016-08-11 03:42:35 +00:00
const plugins = [
new webpack.DefinePlugin({
2018-03-11 20:24:57 +00:00
"process.env.NODE_ENV": `"${NODE_ENV}"`,
"process.env.ACTIONCABLE": `"${ACTIONCABLE}"`
}),
new webpack.IgnorePlugin(/^mock-firmata$/), // work around bindings.js error
new webpack.ContextReplacementPlugin(/bindings$/, /^$/) // work around bindings.js error
2016-08-11 03:42:35 +00:00
]
const externals = ["bindings"] // work around bindings.js error
2016-08-11 03:42:35 +00:00
if (NODE_ENV === 'production') {
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-10-01 02:49:03 +00:00
const devtool = NODE_ENV === 'production' ? undefined : 'cheap-module-eval-source-map'
module.exports = {
context: __dirname,
2016-08-11 03:42:35 +00:00
plugins,
externals,
2016-10-01 02:49:03 +00:00
devtool,
module: {
loaders: [
{
test: /\.json$/, loader: 'json-loader'
},
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
2016-10-03 00:32:37 +00:00
loader: 'babel-loader?cacheDirectory&retainLines=true'
}
]
},
entry: {
2018-02-15 18:47:28 +00:00
'metamaps.bundle': './src/index.js'
},
2018-02-15 18:47:28 +00:00
devServer: {
contentBase: './public'
},
output: {
2018-02-15 18:47:28 +00:00
path: __dirname + '/public',
2016-10-01 04:32:40 +00:00
filename: '[name].js',
2018-02-15 19:16:54 +00:00
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
publicPath: '/'
}
}