Enable the ServiceWorker
This commit is contained in:
parent
fdb298c417
commit
40ac9bece9
|
@ -1,11 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import './precheck';
|
import './precheck';
|
||||||
// import * as OfflinePluginRuntime from '@lcdp/offline-plugin/runtime';
|
import * as OfflinePluginRuntime from '@lcdp/offline-plugin/runtime';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
// import { NODE_ENV } from 'soapbox/build_config';
|
import { NODE_ENV } from 'soapbox/build_config';
|
||||||
|
|
||||||
import { default as Soapbox } from './containers/soapbox';
|
import { default as Soapbox } from './containers/soapbox';
|
||||||
import * as monitoring from './monitoring';
|
import * as monitoring from './monitoring';
|
||||||
|
@ -23,10 +23,10 @@ function main() {
|
||||||
|
|
||||||
ReactDOM.render(<Soapbox />, mountNode);
|
ReactDOM.render(<Soapbox />, mountNode);
|
||||||
|
|
||||||
// if (NODE_ENV === 'production') {
|
if (NODE_ENV === 'production') {
|
||||||
// // avoid offline in dev mode because it's harder to debug
|
// avoid offline in dev mode because it's harder to debug
|
||||||
// OfflinePluginRuntime.install();
|
OfflinePluginRuntime.install();
|
||||||
// }
|
}
|
||||||
perf.stop('main()');
|
perf.stop('main()');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||||
console.log('Running in production mode'); // eslint-disable-line no-console
|
console.log('Running in production mode'); // eslint-disable-line no-console
|
||||||
|
|
||||||
// const { join } = require('path');
|
const { join } = require('path');
|
||||||
|
|
||||||
// const OfflinePlugin = require('@lcdp/offline-plugin');
|
const OfflinePlugin = require('@lcdp/offline-plugin');
|
||||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
|
|
||||||
const sharedConfig = require('./shared');
|
const sharedConfig = require('./shared');
|
||||||
|
|
||||||
// const { FE_SUBDIRECTORY } = require(join(__dirname, '..', 'app', 'soapbox', 'build_config'));
|
const { FE_SUBDIRECTORY } = require(join(__dirname, '..', 'app', 'soapbox', 'build_config'));
|
||||||
// const joinPublicPath = (...paths) => join(FE_SUBDIRECTORY, ...paths);
|
const joinPublicPath = (...paths) => join(FE_SUBDIRECTORY, ...paths);
|
||||||
|
|
||||||
module.exports = merge(sharedConfig, {
|
module.exports = merge(sharedConfig, {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
|
@ -28,97 +28,97 @@ module.exports = merge(sharedConfig, {
|
||||||
openAnalyzer: false,
|
openAnalyzer: false,
|
||||||
logLevel: 'silent',
|
logLevel: 'silent',
|
||||||
}),
|
}),
|
||||||
// new OfflinePlugin({
|
new OfflinePlugin({
|
||||||
// caches: {
|
caches: {
|
||||||
// main: [':rest:'],
|
main: [':rest:'],
|
||||||
// additional: [
|
additional: [
|
||||||
// ':externals:',
|
':externals:',
|
||||||
// 'packs/images/32-*.png', // used in emoji-mart
|
'packs/images/32-*.png', // used in emoji-mart
|
||||||
// 'packs/icons/*.svg',
|
'packs/icons/*.svg',
|
||||||
// ],
|
],
|
||||||
// optional: [
|
optional: [
|
||||||
// '**/locale_*.js', // don't fetch every locale; the user only needs one
|
'**/locale_*.js', // don't fetch every locale; the user only needs one
|
||||||
// '**/*_polyfills-*.js', // the user may not need polyfills
|
'**/*_polyfills-*.js', // the user may not need polyfills
|
||||||
// '**/*.chunk.js', // only cache chunks when needed
|
'**/*.chunk.js', // only cache chunks when needed
|
||||||
// '**/*.chunk.css',
|
'**/*.chunk.css',
|
||||||
// '**/*.woff2', // the user may have system-fonts enabled
|
'**/*.woff2', // the user may have system-fonts enabled
|
||||||
// // images can be cached on-demand
|
// images can be cached on-demand
|
||||||
// '**/*.png',
|
'**/*.png',
|
||||||
// '**/*.svg',
|
'**/*.svg',
|
||||||
// ],
|
],
|
||||||
// },
|
},
|
||||||
// externals: [
|
externals: [
|
||||||
// joinPublicPath('packs/emoji/1f602.svg'), // used for emoji picker dropdown
|
joinPublicPath('packs/emoji/1f602.svg'), // used for emoji picker dropdown
|
||||||
//
|
|
||||||
// // Default emoji reacts
|
// Default emoji reacts
|
||||||
// joinPublicPath('packs/emoji/1f44d.svg'), // Thumbs up
|
joinPublicPath('packs/emoji/1f44d.svg'), // Thumbs up
|
||||||
// joinPublicPath('packs/emoji/2764.svg'), // Heart
|
joinPublicPath('packs/emoji/2764.svg'), // Heart
|
||||||
// joinPublicPath('packs/emoji/1f606.svg'), // Laughing
|
joinPublicPath('packs/emoji/1f606.svg'), // Laughing
|
||||||
// joinPublicPath('packs/emoji/1f62e.svg'), // Surprised
|
joinPublicPath('packs/emoji/1f62e.svg'), // Surprised
|
||||||
// joinPublicPath('packs/emoji/1f622.svg'), // Crying
|
joinPublicPath('packs/emoji/1f622.svg'), // Crying
|
||||||
// joinPublicPath('packs/emoji/1f629.svg'), // Weary
|
joinPublicPath('packs/emoji/1f629.svg'), // Weary
|
||||||
// joinPublicPath('packs/emoji/1f621.svg'), // Angry (Spinster)
|
joinPublicPath('packs/emoji/1f621.svg'), // Angry (Spinster)
|
||||||
// ],
|
],
|
||||||
// excludes: [
|
excludes: [
|
||||||
// '**/*.gz',
|
'**/*.gz',
|
||||||
// '**/*.map',
|
'**/*.map',
|
||||||
// '**/*.LICENSE.txt',
|
'**/*.LICENSE.txt',
|
||||||
// 'stats.json',
|
'stats.json',
|
||||||
// 'report.html',
|
'report.html',
|
||||||
// 'instance/**/*',
|
'instance/**/*',
|
||||||
// // any browser that supports ServiceWorker will support woff2
|
// any browser that supports ServiceWorker will support woff2
|
||||||
// '**/*.eot',
|
'**/*.eot',
|
||||||
// '**/*.ttf',
|
'**/*.ttf',
|
||||||
// '**/*-webfont-*.svg',
|
'**/*-webfont-*.svg',
|
||||||
// '**/*.woff',
|
'**/*.woff',
|
||||||
// // Sounds return a 206 causing sw.js to crash
|
// Sounds return a 206 causing sw.js to crash
|
||||||
// // https://stackoverflow.com/a/66335638
|
// https://stackoverflow.com/a/66335638
|
||||||
// '**/*.ogg',
|
'**/*.ogg',
|
||||||
// '**/*.oga',
|
'**/*.oga',
|
||||||
// '**/*.mp3',
|
'**/*.mp3',
|
||||||
// '404.html',
|
'404.html',
|
||||||
// 'assets-manifest.json',
|
'assets-manifest.json',
|
||||||
// // It would be nice to serve these, but they bloat up sw.js
|
// It would be nice to serve these, but they bloat up sw.js
|
||||||
// 'packs/images/crypto/**/*',
|
'packs/images/crypto/**/*',
|
||||||
// 'packs/emoji/**/*',
|
'packs/emoji/**/*',
|
||||||
// ],
|
],
|
||||||
// ServiceWorker: {
|
ServiceWorker: {
|
||||||
// cacheName: 'soapbox',
|
cacheName: 'soapbox',
|
||||||
// entry: join(__dirname, '../app/soapbox/service_worker/entry.js'),
|
entry: join(__dirname, '../app/soapbox/service_worker/entry.js'),
|
||||||
// minify: true,
|
minify: true,
|
||||||
// },
|
},
|
||||||
// cacheMaps: [{
|
cacheMaps: [{
|
||||||
// match: requestUrl => {
|
match: requestUrl => {
|
||||||
// const backendRoutes = [
|
const backendRoutes = [
|
||||||
// '/api',
|
'/api',
|
||||||
// '/pleroma',
|
'/pleroma',
|
||||||
// '/nodeinfo',
|
'/nodeinfo',
|
||||||
// '/socket',
|
'/socket',
|
||||||
// '/oauth',
|
'/oauth',
|
||||||
// '/.well-known/webfinger',
|
'/.well-known/webfinger',
|
||||||
// '/static',
|
'/static',
|
||||||
// '/instance',
|
'/instance',
|
||||||
// '/main/ostatus',
|
'/main/ostatus',
|
||||||
// '/ostatus_subscribe',
|
'/ostatus_subscribe',
|
||||||
// '/pghero',
|
'/pghero',
|
||||||
// '/sidekiq',
|
'/sidekiq',
|
||||||
// '/open-source',
|
'/open-source',
|
||||||
// ];
|
];
|
||||||
//
|
|
||||||
// const isBackendRoute = ({ pathname }) => {
|
const isBackendRoute = ({ pathname }) => {
|
||||||
// if (pathname) {
|
if (pathname) {
|
||||||
// return backendRoutes.some(pathname.startsWith);
|
return backendRoutes.some(pathname.startsWith);
|
||||||
// } else {
|
} else {
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// return isBackendRoute(requestUrl) && requestUrl;
|
return isBackendRoute(requestUrl) && requestUrl;
|
||||||
// },
|
},
|
||||||
// requestTypes: ['navigate'],
|
requestTypes: ['navigate'],
|
||||||
// }],
|
}],
|
||||||
// safeToUseOptionalCaches: true,
|
safeToUseOptionalCaches: true,
|
||||||
// appShell: join(FE_SUBDIRECTORY, '/'),
|
appShell: join(FE_SUBDIRECTORY, '/'),
|
||||||
// }),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue