You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
soapbox/webpack/production.js

81 lines
2.4 KiB

5 years ago
// Note: You must restart bin/webpack-dev-server for changes to take effect
console.log('Running in production mode'); // eslint-disable-line no-console
5 years ago
const { merge } = require('webpack-merge');
5 years ago
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const OfflinePlugin = require('@lcdp/offline-plugin');
5 years ago
const sharedConfig = require('./shared');
module.exports = merge(sharedConfig, {
5 years ago
mode: 'production',
devtool: 'source-map',
stats: 'errors-warnings',
5 years ago
bail: true,
optimization: {
minimize: true,
},
plugins: [
// Generates report.html
new BundleAnalyzerPlugin({
5 years ago
analyzerMode: 'static',
openAnalyzer: false,
logLevel: 'silent',
5 years ago
}),
new OfflinePlugin({
caches: {
main: [':rest:'],
additional: [':externals:'],
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
5 years ago
'**/*.woff2', // the user may have system-fonts enabled
// images/audio can be cached on-demand
'**/*.png',
'**/*.jpg',
'**/*.jpeg',
'**/*.svg',
'**/*.mp3',
'**/*.ogg',
],
},
externals: [
'/emoji/1f602.svg', // used for emoji picker dropdown
'/emoji/sheet_13.png', // used in emoji-mart
// Default emoji reacts
'/emoji/1f44d.svg', // Thumbs up
'/emoji/2764.svg', // Heart
'/emoji/1f606.svg', // Laughing
'/emoji/1f62e.svg', // Surprised
'/emoji/1f622.svg', // Crying
'/emoji/1f629.svg', // Weary
'/emoji/1f621.svg', // Angry (Spinster)
5 years ago
],
excludes: [
'**/*.gz',
'**/*.map',
'stats.json',
'report.html',
'instance',
5 years ago
// 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
'sounds/**/*',
// Don't cache index.html
'index.html',
5 years ago
],
// ServiceWorker: {
// entry: join(__dirname, '../app/soapbox/service_worker/entry.js'),
// cacheName: 'soapbox',
5 years ago
// minify: true,
// },
}),
],
});