Skip to content

Commit

Permalink
build: ds-776 move required packages to prod deps (#449)
Browse files Browse the repository at this point in the history
Relates to JIRA: DISCOVERY-776
  • Loading branch information
cdcabrera authored Sep 27, 2024
1 parent b00c770 commit 82cd550
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 1,074 deletions.
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN dnf update -y && dnf clean all
# install dependencies in a separate layer to save dev time
WORKDIR /app
COPY package.json package-lock.json .
RUN npm install
RUN npm install --omit=dev

COPY . .
RUN npm run build
Expand Down
33 changes: 32 additions & 1 deletion config/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
const fs = require('fs');
const path = require('path');
const { setBranding } = require('./webpack.common');

module.exports = ({ REACT_APP_UI_BRAND, REACT_APP_UI_BRAND_NAME, REACT_APP_UI_NAME } = {}) => {
/**
* Update a tsconfig file for webpack.
* ts-loader ignores the "exclude" webpack configuration option therefore we dynamically update tsconfig.json to hide
* test files. After the dynamic update and build we attempt a git clean up from "./scripts/post.sh".
* Git clean up can be removed if the build is limited to specific environments other than development.
*
* @param {object} params
* @param {string} params.filePath
* @param {object} params.addConfiguration
* @param {string} params.encoding
*/
const updateTsConfig = ({ filePath, addConfiguration, encoding = 'utf8' } = {}) => {
try {
// eslint-disable-next-line global-require
const currentConfig = require(filePath);
const updatedContents = `${JSON.stringify({ ...currentConfig, ...addConfiguration }, null, 2)}\n`;
fs.writeFileSync(filePath, updatedContents, { encoding });
} catch (e) {
console.error('Updating tsconfig.json failed.', e.message);
}
};

module.exports = ({ RELATIVE_DIRNAME, REACT_APP_UI_BRAND, REACT_APP_UI_BRAND_NAME, REACT_APP_UI_NAME } = {}) => {
setBranding({ isBrand: REACT_APP_UI_BRAND === 'true', brandName: REACT_APP_UI_BRAND_NAME, name: REACT_APP_UI_NAME });

updateTsConfig({
filePath: path.resolve(RELATIVE_DIRNAME, 'tsconfig.json'),
addConfiguration: {
exclude: ['**/*.test.ts', '**/*.test.tsx']
}
});

return {
ignoreWarnings: [
{
Expand Down
Loading

0 comments on commit 82cd550

Please sign in to comment.