soapbox/webpack/production.ts

47 wiersze
1.2 KiB
TypeScript
Czysty Zwykły widok Historia

2020-03-27 20:59:38 +00:00
// Note: You must restart bin/webpack-dev-server for changes to take effect
console.log('Running in production mode'); // eslint-disable-line no-console
2020-03-27 20:59:38 +00:00
import { join } from 'path';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import { merge } from 'webpack-merge';
2023-01-10 20:53:40 +00:00
import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
import sharedConfig from './shared';
import type { Configuration } from 'webpack';
2020-03-27 20:59:38 +00:00
const configuration: Configuration = {
2020-03-27 20:59:38 +00:00
mode: 'production',
devtool: 'source-map',
2021-09-04 21:05:20 +00:00
stats: 'errors-warnings',
2020-03-27 20:59:38 +00:00
bail: true,
output: {
filename: 'packs/js/[name]-[chunkhash].js',
chunkFilename: 'packs/js/[name]-[chunkhash].chunk.js',
hotUpdateChunkFilename: 'packs/js/[id]-[contenthash].hot-update.js',
},
2020-03-27 20:59:38 +00:00
optimization: {
minimize: true,
},
plugins: [
2021-09-05 21:42:48 +00:00
// Generates report.html
2023-01-10 20:53:40 +00:00
// @ts-ignore
2021-09-05 21:42:48 +00:00
new BundleAnalyzerPlugin({
2020-03-27 20:59:38 +00:00
analyzerMode: 'static',
openAnalyzer: false,
2021-09-05 21:42:48 +00:00
logLevel: 'silent',
2020-03-27 20:59:38 +00:00
}),
2023-01-10 20:53:40 +00:00
new WorkboxWebpackPlugin.InjectManifest({
swSrc: join(__dirname, '../app/soapbox/service-worker/entry.ts'),
swDest: 'sw.js',
exclude: [/.*/],
2022-04-05 19:43:29 +00:00
}),
2020-03-27 20:59:38 +00:00
],
};
export default merge<Configuration>(sharedConfig, configuration);