Skip to content

Commit

Permalink
Added ability to disable source maps generation (cvat-ai#7219)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and amjadsaadeh committed Dec 14, 2023
1 parent bf388af commit ef8460e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM node:lts-slim AS cvat-ui
ARG WA_PAGE_VIEW_HIT
ARG UI_APP_CONFIG
ARG CLIENT_PLUGINS
ARG DISABLE_SOURCE_MAPS
ARG SOURCE_MAPS_TOKEN

ENV TERM=xterm \
Expand All @@ -29,6 +30,7 @@ COPY cvat-canvas3d/ /tmp/cvat-canvas3d/
COPY cvat-canvas/ /tmp/cvat-canvas/
COPY cvat-ui/ /tmp/cvat-ui/
RUN CLIENT_PLUGINS="${CLIENT_PLUGINS}" \
DISABLE_SOURCE_MAPS="${DISABLE_SOURCE_MAPS}" \
UI_APP_CONFIG="${UI_APP_CONFIG}" \
SOURCE_MAPS_TOKEN="${SOURCE_MAPS_TOKEN}" yarn run build:cvat-ui

Expand Down
11 changes: 5 additions & 6 deletions cvat-ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
//
// SPDX-License-Identifier: MIT

/* global
__dirname:true
*/

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
Expand All @@ -16,6 +12,8 @@ const CopyPlugin = require('copy-webpack-plugin');
module.exports = (env) => {
const defaultAppConfig = path.join(__dirname, 'src/config.tsx');
const defaultPlugins = ['plugins/sam'];

const sourceMapsDisabled = process.env.DISABLE_SOURCE_MAPS.toLocaleLowerCase() === 'true';
const appConfigFile = process.env.UI_APP_CONFIG ? process.env.UI_APP_CONFIG : defaultAppConfig;
const pluginsList = process.env.CLIENT_PLUGINS ? [...defaultPlugins, ...process.env.CLIENT_PLUGINS.split(':')]
.map((s) => s.trim()).filter((s) => !!s) : defaultPlugins;
Expand All @@ -32,12 +30,13 @@ module.exports = (env) => {
},
}), {});

console.log('Source maps: ', sourceMapsDisabled ? 'disabled' : 'enabled');
console.log('List of plugins: ', Object.values(transformedPlugins).map((plugin) => plugin.import));

return {
target: 'web',
mode: 'production',
devtool: 'source-map',
devtool: sourceMapsDisabled ? false : 'source-map',
entry: {
'cvat-ui': './src/index.tsx',
...transformedPlugins,
Expand Down Expand Up @@ -196,7 +195,7 @@ module.exports = (env) => {
}
],
}),
...(sourceMapsToken ? [new webpack.SourceMapDevToolPlugin({
...(!sourceMapsDisabled && sourceMapsToken ? [new webpack.SourceMapDevToolPlugin({
append: '\n',
filename: `${sourceMapsToken}/[file].map`,
})] : []),
Expand Down

0 comments on commit ef8460e

Please sign in to comment.