zcash-grant-system/frontend/config/webpack.config.js/client.base.js

83 lines
1.9 KiB
JavaScript

const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const paths = require('../paths');
const { client: clientLoaders } = require('./loaders');
const resolvers = require('./resolvers');
const plugins = require('./plugins');
const isDev = process.env.NODE_ENV === 'development';
module.exports = {
name: 'client',
target: 'web',
entry: {
bundle: [path.join(paths.srcClient, 'index.tsx')],
},
output: {
path: path.join(paths.clientBuild, paths.publicPath),
filename: 'bundle.js',
publicPath: paths.publicPath,
chunkFilename: isDev ? '[name].chunk.js' : '[name].[chunkhash:8].chunk.js',
},
module: {
rules: clientLoaders,
},
resolve: { ...resolvers },
plugins: [...plugins.shared, ...plugins.client],
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: {
// otherwise BN typecheck gets mangled during minification
keep_fnames: true,
},
}),
],
namedModules: true,
noEmitOnErrors: false,
splitChunks: {
chunks: 'async',
minSize: 30000,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
},
stats: {
cached: false,
cachedAssets: false,
chunks: false,
chunkModules: false,
colors: true,
hash: false,
modules: false,
reasons: false,
timings: true,
version: false,
},
};