use dynamic js bundle urls
This commit is contained in:
parent
3b4ac976b6
commit
cb8a801d4a
6 changed files with 24 additions and 4 deletions
|
@ -3,7 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script src="/public/ui.js" async></script>
|
|
||||||
<link rel="icon" type="image/png" href="/public/favicon.png" />
|
<link rel="icon" type="image/png" href="/public/favicon.png" />
|
||||||
|
|
||||||
<link rel="preload" href="/public/font/v1/300.woff" as="font" type="font/woff" />
|
<link rel="preload" href="/public/font/v1/300.woff" as="font" type="font/woff" />
|
||||||
|
|
8
web/bundle-id.js
Normal file
8
web/bundle-id.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
const uuid = require('uuid/v4');
|
||||||
|
const jsBundleId = uuid();
|
||||||
|
|
||||||
|
function getJsBundleId() {
|
||||||
|
return jsBundleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getJsBundleId };
|
|
@ -34,7 +34,8 @@
|
||||||
"lbry-redux": "lbryio/lbry-redux#c107d9cc4c4b2cc31f182f196ab6a033aefe976e",
|
"lbry-redux": "lbryio/lbry-redux#c107d9cc4c4b2cc31f182f196ab6a033aefe976e",
|
||||||
"lbryinc": "lbryio/lbryinc#6a52f8026cdc7cd56d200fb5c46f852e0139bbeb",
|
"lbryinc": "lbryio/lbryinc#6a52f8026cdc7cd56d200fb5c46f852e0139bbeb",
|
||||||
"mysql": "^2.17.1",
|
"mysql": "^2.17.1",
|
||||||
"node-fetch": "^2.6.0"
|
"node-fetch": "^2.6.0",
|
||||||
|
"uuid": "^8.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.0.0",
|
||||||
|
|
|
@ -14,11 +14,16 @@ const { getClaim } = require('./chainquery');
|
||||||
const { parseURI } = require('lbry-redux');
|
const { parseURI } = require('lbry-redux');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { getJsBundleId } = require('../bundle-id.js');
|
||||||
|
const jsBundleId = getJsBundleId();
|
||||||
|
|
||||||
function insertToHead(fullHtml, htmlToInsert) {
|
function insertToHead(fullHtml, htmlToInsert) {
|
||||||
return fullHtml.replace(
|
return fullHtml.replace(
|
||||||
/<!-- VARIABLE_HEAD_BEGIN -->.*<!-- VARIABLE_HEAD_END -->/s,
|
/<!-- VARIABLE_HEAD_BEGIN -->.*<!-- VARIABLE_HEAD_END -->/s,
|
||||||
htmlToInsert || buildOgMetadata()
|
`
|
||||||
|
${htmlToInsert || buildOgMetadata()}
|
||||||
|
<script src="/public/ui-${jsBundleId}.js" async></script>
|
||||||
|
`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ const baseConfig = require('../webpack.base.config.js');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
const { DefinePlugin, ProvidePlugin } = require('webpack');
|
const { DefinePlugin, ProvidePlugin } = require('webpack');
|
||||||
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
|
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
|
||||||
|
const { getJsBundleId } = require('./bundle-id.js');
|
||||||
const { insertToHead, buildBasicOgMetadata } = require('./src/html');
|
const { insertToHead, buildBasicOgMetadata } = require('./src/html');
|
||||||
const { insertVariableXml, getOpenSearchXml } = require('./src/xml');
|
const { insertVariableXml, getOpenSearchXml } = require('./src/xml');
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ const DIST_ROOT = path.resolve(__dirname, 'dist/');
|
||||||
const WEB_PLATFORM_ROOT = __dirname;
|
const WEB_PLATFORM_ROOT = __dirname;
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const hasSentryToken = process.env.SENTRY_AUTH_TOKEN !== undefined;
|
const hasSentryToken = process.env.SENTRY_AUTH_TOKEN !== undefined;
|
||||||
|
const jsBundleId = getJsBundleId();
|
||||||
|
|
||||||
const copyWebpackCommands = [
|
const copyWebpackCommands = [
|
||||||
{
|
{
|
||||||
|
@ -80,7 +82,7 @@ if (isProduction && hasSentryToken) {
|
||||||
const webConfig = {
|
const webConfig = {
|
||||||
target: 'web',
|
target: 'web',
|
||||||
entry: {
|
entry: {
|
||||||
ui: '../ui/index.jsx',
|
[`ui-${jsBundleId}`]: '../ui/index.jsx',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
|
|
|
@ -5413,6 +5413,11 @@ uuid@^3.0.1, uuid@^3.3.2:
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
|
||||||
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
|
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
|
||||||
|
|
||||||
|
uuid@^8.3.0:
|
||||||
|
version "8.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea"
|
||||||
|
integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==
|
||||||
|
|
||||||
vary@^1.1.2, vary@~1.1.2:
|
vary@^1.1.2, vary@~1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
||||||
|
|
Loading…
Reference in a new issue