fix(web): fix web version

This commit is contained in:
Alexey Kasyanchuk
2021-01-07 01:37:10 +03:00
parent 8522f00685
commit 7c3ad12819
4 changed files with 266 additions and 106 deletions

View File

@ -14,7 +14,7 @@ window.__ = __
if(typeof WEB !== 'undefined')
{
const io = require("socket.io");
const io = require("socket.io-client");
window.torrentSocket = io(document.location.protocol + '//' + document.location.hostname + (process.env.NODE_ENV === 'production' ? '/' : ':8095/'));
}
else

View File

@ -47,45 +47,14 @@ module.exports = {
},
}),
new webpack.DefinePlugin({WEB: true}),
// Generate a service worker script that will precache, and keep up to date,
// the HTML & assets that are part of the Webpack build.
new SWPrecacheWebpackPlugin({
// By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped.
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
if (message.indexOf('Skipping static resource') === 0) {
// This message obscures real errors so we ignore it.
// https://github.com/facebookincubator/create-react-app/issues/2612
return;
}
console.log(message);
},
minify: true,
// For unknown URLs, fallback to the index page
navigateFallback: 'index.html',
// Ignores URLs starting from /__ (useful for Firebase):
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
navigateFallbackWhitelist: [/^(?!\/__).*/],
// Don't precache sourcemaps (they're large) and build asset manifest:
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
mergeStaticsConfig: true,
staticFileGlobs: glob.sync('public/images/**/*.*').concat(glob.sync('public/sounds/**/*.*')),
stripPrefix: 'public/',
}),
new CopyWebpackPlugin(['translations/**']),
new CopyWebpackPlugin({patterns: ['translations/**']}),
],
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
},
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
},
}
};