fix production build

pull/2274/head
filip mertens 3 years ago
parent 0c776f156a
commit a038fce751
  1. 15
      apps/remix-ide/src/assets/js/loader.js
  2. 11
      apps/remix-ide/webpack.config.js

@ -4,16 +4,15 @@ createScriptTag = function(url, type) {
script.type = type; script.type = type;
document.getElementsByTagName('head')[0].appendChild(script); document.getElementsByTagName('head')[0].appendChild(script);
}; };
fetch('assets/version.json').then(response => { fetch('assets/version.json').then(response => {
response.text().then(function(data) { response.text().then(function(data) {
const version = JSON.parse(data).version; const version = JSON.parse(data);
console.log(`Loading Remix ${version}`); console.log(`Loading Remix ${version.version}`);
createScriptTag(`polyfills.${version}.js`, 'module'); createScriptTag(`polyfills.${version.version}.${version.timestamp}.js`, 'module');
if (version.includes('dev')) { if (version.mode === 'development') {
createScriptTag(`vendor.${version}.js`, 'module'); createScriptTag(`vendor.${version.version}.${version.timestamp}.js`, 'module');
createScriptTag(`runtime.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');
}); });
}); });

@ -4,9 +4,13 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
const version = require('../../package.json').version const version = require('../../package.json').version
const fs = require('fs') const fs = require('fs')
fs.writeFileSync('./apps/remix-ide/src/assets/version.json', JSON.stringify({ const versionData = {
version: version, 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 => { module.exports = config => {
const nxWebpackConfig = nxWebpack(config) const nxWebpackConfig = nxWebpack(config)
@ -22,7 +26,8 @@ module.exports = config => {
}, },
output: { output: {
...nxWebpackConfig.output, ...nxWebpackConfig.output,
chunkFilename: `[name].${version}.js`, filename: `[name].${versionData.version}.${versionData.timestamp}.js`,
chunkFilename: `[name].${versionData.version}.${versionData.timestamp}.js`,
}, },
plugins: [ plugins: [
...nxWebpackConfig.plugins, ...nxWebpackConfig.plugins,

Loading…
Cancel
Save