Use webpack environment variables in build.sh

This commit is contained in:
Mark McDowall 2021-04-24 18:06:22 -07:00
parent 684626ef73
commit 56a33e3b4c
2 changed files with 229 additions and 229 deletions

View File

@ -141,7 +141,7 @@ Build()
ProgressEnd 'Build'
}
RunGulp()
RunWebpack()
{
ProgressStart 'yarn install'
yarn install
@ -149,9 +149,9 @@ RunGulp()
LintUI
ProgressStart 'Running gulp'
CheckExitCode yarn run build --production
ProgressEnd 'Running gulp'
ProgressStart 'Running webpack'
CheckExitCode yarn run build --env production
ProgressEnd 'Running webpack'
}
CreateMdbs()
@ -447,7 +447,7 @@ esac
UpdateVersionNumber
Build
CreateReleaseInfo
RunGulp
RunWebpack
PackageMono
PackageMacOS
PackageMacOSApp

View File

@ -1,4 +1,3 @@
/* eslint-disable filenames/match-exported */
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
@ -7,21 +6,22 @@ const LiveReloadPlugin = require('webpack-livereload-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const uiFolder = 'UI';
const frontendFolder = path.join(__dirname, '..');
const srcFolder = path.join(frontendFolder, 'src');
const isProduction = process.argv.indexOf('--production') > -1;
const isProfiling = isProduction && process.argv.indexOf('--profile') > -1;
const inlineWebWorkers = 'no-fallback';
module.exports = (env) => {
const uiFolder = 'UI';
const frontendFolder = path.join(__dirname, '..');
const srcFolder = path.join(frontendFolder, 'src');
const isProduction = !!env.production;
const isProfiling = isProduction && !!env.profile;
const inlineWebWorkers = 'no-fallback';
const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder);
const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder);
console.log('Source Folder:', srcFolder);
console.log('Output Folder:', distFolder);
console.log('isProduction:', isProduction);
console.log('isProfiling:', isProfiling);
console.log('Source Folder:', srcFolder);
console.log('Output Folder:', distFolder);
console.log('isProduction:', isProduction);
console.log('isProfiling:', isProfiling);
const config = {
const config = {
mode: isProduction ? 'production' : 'development',
devtool: 'source-map',
@ -237,9 +237,9 @@ const config = {
}
]
}
};
};
if (isProfiling) {
if (isProfiling) {
config.resolve.alias['react-dom$'] = 'react-dom/profiling';
config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
@ -255,7 +255,7 @@ if (isProfiling) {
}
})
];
}
}
module.exports = config;
/* eslint-enable filenames/match-exported */
return config;
};