1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-24 19:10:12 +01:00
js-bigchaindb-driver/webpack.config.js
diminator a338a5c570 restructure driver and make cjs compatible
update examples and tutorials
2017-04-03 17:54:48 +02:00

81 lines
1.7 KiB
JavaScript

/* eslint-disable strict, no-console, object-shorthand */
'use strict';
const path = require('path');
const webpack = require('webpack');
const PRODUCTION = process.env.NODE_ENV === 'production';
const PATHS = {
ENTRY: path.resolve(__dirname, './src/index.js'),
BUNDLE: path.resolve(__dirname, 'dist/bundle'),
NODE_MODULES: path.resolve(__dirname, 'node_modules'),
};
/** PLUGINS **/
const PLUGINS = [
new webpack.NoEmitOnErrorsPlugin(),
];
const PROD_PLUGINS = [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
sourceMap: true,
}),
new webpack.LoaderOptionsPlugin({
debug: false,
minimize: true,
}),
];
if (PRODUCTION) {
PLUGINS.push(...PROD_PLUGINS);
}
/** EXPORTED WEBPACK CONFIG **/
const config = {
entry: [PATHS.ENTRY],
output: {
filename: PRODUCTION ? 'bundle.min.js' : 'bundle.js',
library: 'js-bigchaindb-quickstart',
libraryTarget: 'umd',
path: PATHS.BUNDLE,
},
devtool: PRODUCTION ? '#source-map' : '#inline-source-map',
resolve: {
extensions: ['.js'],
modules: ['node_modules'], // Don't use absolute path here to allow recursive matching
},
plugins: PLUGINS,
module: {
rules: [
{
test: /\.js$/,
exclude: [PATHS.NODE_MODULES],
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
}],
},
],
},
};
module.exports = config;