2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 12:16:52 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
const path = require('path');
|
2022-09-08 15:11:09 +01:00
|
|
|
|
2021-10-11 10:16:01 +01:00
|
|
|
const webpack = require('webpack');
|
2019-08-08 13:12:39 +01:00
|
|
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
2021-06-22 11:16:06 +01:00
|
|
|
const productionBrotliExtensions = ['js', 'css', 'ttf', 'woff', 'woff2'];
|
2021-10-11 10:16:01 +01:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
|
|
|
|
|
|
let plugins = [
|
|
|
|
new CompressionWebpackPlugin({
|
|
|
|
algorithm: 'brotliCompress',
|
|
|
|
filename: '[path][name].br',
|
|
|
|
test: new RegExp('\\.(' + productionBrotliExtensions.join('|') + ')$'),
|
|
|
|
threshold: 1024,
|
2022-09-08 15:11:09 +01:00
|
|
|
minRatio: 0.8,
|
2021-10-11 10:16:01 +01:00
|
|
|
}),
|
|
|
|
new webpack.optimize.MinChunkSizePlugin({
|
|
|
|
minChunkSize: 50*1024,
|
|
|
|
}),
|
2022-04-07 12:04:24 +01:00
|
|
|
new webpack.IgnorePlugin({
|
|
|
|
contextRegExp: /bip39[\\/]src$/,
|
|
|
|
resourceRegExp: /^\.\/wordlists\/(?!english)/,
|
|
|
|
}),
|
2022-05-05 16:16:27 +01:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
|
|
|
}),
|
2021-10-11 10:16:01 +01:00
|
|
|
];
|
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
if (process.env['STORJ_DEBUG_BUNDLE_SIZE']) {
|
2021-10-11 10:16:01 +01:00
|
|
|
plugins.push(new BundleAnalyzerPlugin());
|
|
|
|
}
|
2019-07-30 11:13:24 +01:00
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
module.exports = {
|
2022-09-08 15:11:09 +01:00
|
|
|
publicPath: '/static/dist',
|
2019-07-30 11:13:24 +01:00
|
|
|
productionSourceMap: false,
|
|
|
|
parallel: true,
|
2022-04-07 12:04:24 +01:00
|
|
|
lintOnSave: process.env.NODE_ENV !== 'production', // disables eslint for builds
|
2019-08-08 13:12:39 +01:00
|
|
|
configureWebpack: {
|
2021-10-11 10:16:01 +01:00
|
|
|
plugins: plugins,
|
2022-04-07 12:04:24 +01:00
|
|
|
resolve: {
|
|
|
|
fallback: {
|
2022-09-08 15:11:09 +01:00
|
|
|
'util': require.resolve('util/'),
|
|
|
|
'stream': require.resolve('stream-browserify'),
|
|
|
|
'buffer': require.resolve('buffer'),
|
2022-04-07 12:04:24 +01:00
|
|
|
},
|
2022-09-08 15:11:09 +01:00
|
|
|
},
|
2019-08-08 13:12:39 +01:00
|
|
|
},
|
2018-11-05 15:26:18 +00:00
|
|
|
chainWebpack: config => {
|
2022-04-07 12:04:24 +01:00
|
|
|
// Avoid breaking browser UI cache.
|
2022-05-11 15:18:33 +01:00
|
|
|
config.output.chunkFilename(`js/vendors_[name]_[chunkhash].js`);
|
|
|
|
config.output.filename(`js/app_[name]_[chunkhash].js`);
|
2019-08-08 13:12:39 +01:00
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
config.resolve.alias
|
|
|
|
.set('@', path.resolve('src'));
|
2019-06-18 14:36:54 +01:00
|
|
|
|
2022-04-07 12:04:24 +01:00
|
|
|
// Disable node_modules/.cache directory usage due to permissions.
|
|
|
|
// This is enabled by default in https://cli.vuejs.org/core-plugins/babel.html#caching.
|
|
|
|
config.module.rule('js').use('babel-loader')
|
2022-09-08 15:11:09 +01:00
|
|
|
.tap(options => Object.assign(options, { cacheDirectory: false }));
|
2022-04-07 12:04:24 +01:00
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
config
|
|
|
|
.plugin('html')
|
|
|
|
.tap(args => {
|
|
|
|
args[0].template = './index.html';
|
2022-04-07 12:04:24 +01:00
|
|
|
return args;
|
2019-07-30 11:13:24 +01:00
|
|
|
});
|
2019-10-23 13:26:39 +01:00
|
|
|
|
|
|
|
const svgRule = config.module.rule('svg');
|
|
|
|
svgRule.uses.clear();
|
2022-04-07 12:04:24 +01:00
|
|
|
svgRule.type(); // Disable webpack 5 asset management.
|
2019-10-23 13:26:39 +01:00
|
|
|
svgRule
|
2022-04-07 12:04:24 +01:00
|
|
|
.use('vue-loader')
|
|
|
|
.loader('vue-loader')
|
2019-11-22 17:22:37 +00:00
|
|
|
.end()
|
2019-10-23 13:26:39 +01:00
|
|
|
.use('vue-svg-loader')
|
|
|
|
.loader('vue-svg-loader');
|
2022-04-07 12:04:24 +01:00
|
|
|
},
|
2019-07-30 11:13:24 +01:00
|
|
|
};
|