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');
|
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');
|
2020-12-15 18:48:34 +00:00
|
|
|
const WorkerPlugin = require('worker-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,
|
|
|
|
minRatio: 0.8
|
|
|
|
}),
|
|
|
|
new WorkerPlugin({
|
|
|
|
globalObject: 'self',
|
|
|
|
}),
|
|
|
|
new webpack.optimize.MinChunkSizePlugin({
|
|
|
|
minChunkSize: 50*1024,
|
|
|
|
}),
|
|
|
|
new webpack.IgnorePlugin(/^\.\/wordlists\/(?!english)/, /bip39[\\/]src$/),
|
|
|
|
];
|
|
|
|
|
|
|
|
if(process.env["STORJ_DEBUG_BUNDLE_SIZE"]) {
|
|
|
|
plugins.push(new BundleAnalyzerPlugin());
|
|
|
|
}
|
2019-07-30 11:13:24 +01:00
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
module.exports = {
|
2019-07-30 11:13:24 +01:00
|
|
|
publicPath: "/static/dist",
|
|
|
|
productionSourceMap: false,
|
|
|
|
parallel: true,
|
2021-10-11 10:16:01 +01:00
|
|
|
lintOnSave: false, // disables eslint for builds
|
2019-08-08 13:12:39 +01:00
|
|
|
configureWebpack: {
|
2021-10-11 10:16:01 +01:00
|
|
|
plugins: plugins,
|
2019-08-08 13:12:39 +01:00
|
|
|
},
|
2018-11-05 15:26:18 +00:00
|
|
|
chainWebpack: config => {
|
2020-03-19 16:40:41 +00:00
|
|
|
config.output.chunkFilename(`js/vendors_[name]_[hash].js`);
|
|
|
|
config.output.filename(`js/app_[hash].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
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
config
|
|
|
|
.plugin('html')
|
|
|
|
.tap(args => {
|
|
|
|
args[0].template = './index.html';
|
|
|
|
return args
|
|
|
|
});
|
2019-10-23 13:26:39 +01:00
|
|
|
|
|
|
|
const svgRule = config.module.rule('svg');
|
|
|
|
|
|
|
|
svgRule.uses.clear();
|
|
|
|
|
|
|
|
svgRule
|
2019-11-22 17:22:37 +00:00
|
|
|
.use('babel-loader')
|
|
|
|
.loader('babel-loader')
|
|
|
|
.end()
|
2019-10-23 13:26:39 +01:00
|
|
|
.use('vue-svg-loader')
|
|
|
|
.loader('vue-svg-loader');
|
2019-07-30 11:13:24 +01:00
|
|
|
}
|
|
|
|
};
|