Skip to content

Commit

Permalink
Webpack dev server proxy (cvat-ai#3368)
Browse files Browse the repository at this point in the history
* Added proxy to webpack dev server config

* Added CHANGELOG increased package version

* Added webpack.config to eslintignore

* Added webpack.config to eslintignore

* Changed ignore to wildcard

* Changed path checker to regexp
  • Loading branch information
ActiveChooN authored Jun 29, 2021
1 parent c8b0521 commit 961bc58
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ keys/
logs/
static/
templates/
*/webpack.config.js
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Updated manifest format, added meta with related images (<https://github.com/openvinotoolkit/cvat/pull/3122>)
- Update of COCO format documentation (<https://github.com/openvinotoolkit/cvat/pull/3197>)
- Updated Webpack Dev Server config to add proxxy (<https://github.com/openvinotoolkit/cvat/pull/3368>)

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2019-2020 Intel Corporation
// Copyright (C) 2019-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

module.exports = {
backendAPI: 'http://localhost:7000/api/v1',
backendAPI: '/api/v1',
proxy: false,
};
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "cvat-ui",
"version": "1.20.5",
"version": "1.20.6",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
"build": "webpack --config ./webpack.config.js",
"start": "REACT_APP_API_URL=http://localhost:7000 webpack-dev-server --config ./webpack.config.js --mode=development",
"start": "webpack-dev-server --env.API_URL=http://localhost:7000 --config ./webpack.config.js --mode=development",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"lint": "eslint './src/**/*.{ts,tsx}'",
Expand Down
5 changes: 2 additions & 3 deletions cvat-ui/src/cvat-core-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

import _cvat from 'cvat-core/src/api';

const cvat: any = _cvat;

cvat.config.backendAPI =
typeof process.env.REACT_APP_API_URL === 'undefined' ? '/api/v1' : `${process.env.REACT_APP_API_URL}/api/v1`;
cvat.config.backendAPI = '/api/v1';

export default function getCore(): any {
return cvat;
Expand Down
17 changes: 14 additions & 3 deletions cvat-ui/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -12,7 +12,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const CopyPlugin = require('copy-webpack-plugin');

module.exports = {
module.exports = (env) => ({
target: 'web',
mode: 'production',
devtool: 'source-map',
Expand All @@ -30,6 +30,17 @@ module.exports = {
inline: true,
port: 3000,
historyApiFallback: true,
proxy: [
{
context: (param) =>
param.match(
/\/api\/.*|git\/.*|opencv\/.*|analytics\/.*|static\/.*|admin(?:\/(.*))?.*|documentation\/.*|django-rq(?:\/(.*))?/gm,
),
target: env && env.API_URL,
secure: false,
changeOrigin: true,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
Expand Down Expand Up @@ -134,4 +145,4 @@ module.exports = {
]),
],
node: { fs: 'empty' },
};
});

0 comments on commit 961bc58

Please sign in to comment.