Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to disable source maps generation #7219

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading