diff --git a/Dockerfile.ui b/Dockerfile.ui index 511fd9297d02..1cf05dd101ad 100644 --- a/Dockerfile.ui +++ b/Dockerfile.ui @@ -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 \ @@ -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 diff --git a/cvat-ui/webpack.config.js b/cvat-ui/webpack.config.js index 273d8427c707..ba7e176e7751 100644 --- a/cvat-ui/webpack.config.js +++ b/cvat-ui/webpack.config.js @@ -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'); @@ -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; @@ -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, @@ -196,7 +195,7 @@ module.exports = (env) => { } ], }), - ...(sourceMapsToken ? [new webpack.SourceMapDevToolPlugin({ + ...(!sourceMapsDisabled && sourceMapsToken ? [new webpack.SourceMapDevToolPlugin({ append: '\n', filename: `${sourceMapsToken}/[file].map`, })] : []),