From a038fce7518417a6758c23d6c4e750ea7991d7de Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 11 Apr 2022 08:25:16 +0200 Subject: [PATCH] fix production build --- apps/remix-ide/src/assets/js/loader.js | 15 +++++++-------- apps/remix-ide/webpack.config.js | 11 ++++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/assets/js/loader.js b/apps/remix-ide/src/assets/js/loader.js index 78edd692fa..3052f70db2 100644 --- a/apps/remix-ide/src/assets/js/loader.js +++ b/apps/remix-ide/src/assets/js/loader.js @@ -4,16 +4,15 @@ createScriptTag = function(url, type) { script.type = type; document.getElementsByTagName('head')[0].appendChild(script); }; - fetch('assets/version.json').then(response => { response.text().then(function(data) { - const version = JSON.parse(data).version; - console.log(`Loading Remix ${version}`); - createScriptTag(`polyfills.${version}.js`, 'module'); - if (version.includes('dev')) { - createScriptTag(`vendor.${version}.js`, 'module'); - createScriptTag(`runtime.js`, 'module'); + const version = JSON.parse(data); + console.log(`Loading Remix ${version.version}`); + createScriptTag(`polyfills.${version.version}.${version.timestamp}.js`, 'module'); + if (version.mode === 'development') { + createScriptTag(`vendor.${version.version}.${version.timestamp}.js`, 'module'); + createScriptTag(`runtime.${version.version}.${version.timestamp}.js`, 'module'); } - createScriptTag(`main.${version}.js`, 'text/javascript'); + createScriptTag(`main.${version.version}.${version.timestamp}.js`, 'text/javascript'); }); }); diff --git a/apps/remix-ide/webpack.config.js b/apps/remix-ide/webpack.config.js index 502b0d21aa..529fe58d39 100644 --- a/apps/remix-ide/webpack.config.js +++ b/apps/remix-ide/webpack.config.js @@ -4,9 +4,13 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') const version = require('../../package.json').version const fs = require('fs') -fs.writeFileSync('./apps/remix-ide/src/assets/version.json', JSON.stringify({ +const versionData = { version: version, -})) + timestamp: Date.now(), + mode: process.env.NODE_ENV === 'production' ? 'production' : 'development' +} + +fs.writeFileSync('./apps/remix-ide/src/assets/version.json', JSON.stringify(versionData)) module.exports = config => { const nxWebpackConfig = nxWebpack(config) @@ -22,7 +26,8 @@ module.exports = config => { }, output: { ...nxWebpackConfig.output, - chunkFilename: `[name].${version}.js`, + filename: `[name].${versionData.version}.${versionData.timestamp}.js`, + chunkFilename: `[name].${versionData.version}.${versionData.timestamp}.js`, }, plugins: [ ...nxWebpackConfig.plugins,