soapbox/webpack/production.js

82 wiersze
2.5 KiB
JavaScript
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
2020-10-07 21:33:56 +00:00
const { merge } = require('webpack-merge');
2020-03-27 20:59:38 +00:00
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
2021-09-05 21:42:48 +00:00
const OfflinePlugin = require('@lcdp/offline-plugin');
2020-03-27 20:59:38 +00:00
const sharedConfig = require('./shared');
2021-09-05 21:42:48 +00:00
module.exports = merge(sharedConfig, {
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,
optimization: {
minimize: true,
},
plugins: [
2021-09-05 21:42:48 +00:00
// Generates report.html
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
}),
new OfflinePlugin({
caches: {
main: [':rest:'],
2021-09-11 01:11:36 +00:00
additional: [
'packs/emoji/1f602-*.svg', // used for emoji picker dropdown
'packs/images/32-*.png', // used in emoji-mart
// Default emoji reacts
'packs/emoji/1f44d-*.svg', // Thumbs up
'packs/emoji/2764-*.svg', // Heart
'packs/emoji/1f606-*.svg', // Laughing
'packs/emoji/1f62e-*.svg', // Surprised
'packs/emoji/1f622-*.svg', // Crying
'packs/emoji/1f629-*.svg', // Weary
'packs/emoji/1f621-*.svg', // Angry (Spinster)
],
2020-03-27 20:59:38 +00:00
optional: [
'**/locale_*.js', // don't fetch every locale; the user only needs one
'**/*_polyfills-*.js', // the user may not need polyfills
'**/*.chunk.js', // only cache chunks when needed
2020-03-27 20:59:38 +00:00
'**/*.woff2', // the user may have system-fonts enabled
// images can be cached on-demand
2020-03-27 20:59:38 +00:00
'**/*.png',
'**/*.svg',
],
},
excludes: [
'**/*.gz',
'**/*.map',
2021-09-11 01:11:36 +00:00
'**/*.LICENSE.txt',
2020-03-27 20:59:38 +00:00
'stats.json',
'report.html',
'instance/**/*',
2020-03-27 20:59:38 +00:00
// any browser that supports ServiceWorker will support woff2
'**/*.eot',
'**/*.ttf',
'**/*-webfont-*.svg',
'**/*.woff',
// Sounds return a 206 causing sw.js to crash
// https://stackoverflow.com/a/66335638
'**/*.ogg',
'**/*.oga',
'**/*.mp3',
2021-09-11 01:11:36 +00:00
// Don't serve index.html
// https://github.com/bromite/bromite/issues/1294
'index.html',
2021-09-11 01:11:36 +00:00
'404.html',
2020-03-27 20:59:38 +00:00
],
// ServiceWorker: {
// entry: join(__dirname, '../app/soapbox/service_worker/entry.js'),
2020-05-28 22:52:07 +00:00
// cacheName: 'soapbox',
2020-03-27 20:59:38 +00:00
// minify: true,
// },
safeToUseOptionalCaches: true,
2020-03-27 20:59:38 +00:00
}),
],
2021-09-05 21:42:48 +00:00
});