Skip to content

Commit

Permalink
fix: Updated config to support favicon (#4179)
Browse files Browse the repository at this point in the history
Signed-off-by: Hrishav <hrishav.kumar@harness.io>
  • Loading branch information
hrishavjha authored Sep 20, 2023
1 parent ac62acf commit ed9728a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 47 deletions.
8 changes: 8 additions & 0 deletions chaoscenter/web/config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { GenerateStringTypesPlugin } = require('../scripts/GenerateStringTypesPlugin');
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

const CONTEXT = process.cwd();

Expand Down Expand Up @@ -157,6 +158,13 @@ module.exports = {
}
}
]
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/static'
}
]
})
]
};
75 changes: 36 additions & 39 deletions chaoscenter/web/config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ const commonConfig = require('./webpack.common');
require('dotenv').config();

const CONTEXT = process.cwd();
const isCI = process.env.CI === 'true';
const baseUrl = process.env.BASE_URL;
const targetLocalHost = (process.env.TARGET_LOCALHOST && JSON.parse(process.env.TARGET_LOCALHOST)) ?? true; // set to false to target baseUrl environment instead of localhost

const certificateExists = fs.existsSync(path.join(CONTEXT, 'certificates/localhost.pem'));

// certificates are required in non CI environments only
if (!isCI && !certificateExists) {
if (!certificateExists) {
throw new Error('The certificate is missing, please run `yarn generate-certificate`');
}

Expand All @@ -27,44 +26,42 @@ const devConfig = {
filename: '[name].js',
chunkFilename: '[name].[id].js'
},
devServer: isCI
? undefined
: {
static: [path.join(process.cwd(), 'src/static')],
historyApiFallback: true,
port: 8185,
server: {
type: 'https',
options: {
key: fs.readFileSync(path.resolve(CONTEXT, 'certificates/localhost-key.pem')),
cert: fs.readFileSync(path.resolve(CONTEXT, 'certificates/localhost.pem'))
}
},
proxy: {
'/api': {
pathRewrite: { '^/api': '' },
target: process.env.CHAOS_MANAGER
? process.env.CHAOS_MANAGER
: targetLocalHost
? 'http://localhost:8080'
: `${baseUrl}/api`,
secure: false,
changeOrigin: true,
logLevel: 'info'
},
'/auth': {
pathRewrite: { '^/auth': '' },
target: process.env.CHAOS_MANAGER
? process.env.CHAOS_MANAGER
: targetLocalHost
? 'http://localhost:3000'
: `${baseUrl}/auth`,
secure: false,
changeOrigin: true,
logLevel: 'info'
}
}
devServer: {
static: [path.join(process.cwd(), 'src/static')],
historyApiFallback: true,
port: 8185,
server: {
type: 'https',
options: {
key: fs.readFileSync(path.resolve(CONTEXT, 'certificates/localhost-key.pem')),
cert: fs.readFileSync(path.resolve(CONTEXT, 'certificates/localhost.pem'))
}
},
proxy: {
'/api': {
pathRewrite: { '^/api': '' },
target: process.env.CHAOS_MANAGER
? process.env.CHAOS_MANAGER
: targetLocalHost
? 'http://localhost:8080'
: `${baseUrl}/api`,
secure: false,
changeOrigin: true,
logLevel: 'info'
},
'/auth': {
pathRewrite: { '^/auth': '' },
target: process.env.CHAOS_MANAGER
? process.env.CHAOS_MANAGER
: targetLocalHost
? 'http://localhost:3000'
: `${baseUrl}/auth`,
secure: false,
changeOrigin: true,
logLevel: 'info'
}
}
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
Expand Down
1 change: 1 addition & 0 deletions chaoscenter/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"circular-dependency-plugin": "^5.2.2",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.4.0",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
Expand Down
5 changes: 5 additions & 0 deletions chaoscenter/web/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/favicon.ico" />
<meta name="msapplication-TileImage" content="/favicon.ico" />
<meta name="msapplication-TileColor" content="#878ede" />
<link rel="shortcut icon" href="/favicon.ico" />
<title>LitmusChaos</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;700&display=swap" rel="stylesheet" />
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="react-root"></div>
</body>
</html>
35 changes: 27 additions & 8 deletions chaoscenter/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3030,6 +3030,18 @@ copy-to-clipboard@^3.2.0:
dependencies:
toggle-selection "^1.0.6"

copy-webpack-plugin@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz#96d4dbdb5f73d02dd72d0528d1958721ab72e04a"
integrity sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==
dependencies:
fast-glob "^3.2.11"
glob-parent "^6.0.1"
globby "^13.1.1"
normalize-path "^3.0.0"
schema-utils "^4.0.0"
serialize-javascript "^6.0.0"

core-js@^2.4.0:
version "2.6.12"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
Expand Down Expand Up @@ -4239,21 +4251,21 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-glob@^3.2.9:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
fast-glob@^3.2.11, fast-glob@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4"
integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
glob-parent "^5.1.2"
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-glob@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4"
integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==
fast-glob@^3.2.9:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
Expand Down Expand Up @@ -4548,6 +4560,13 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
dependencies:
is-glob "^4.0.1"

glob-parent@^6.0.1:
version "6.0.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3"
integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==
dependencies:
is-glob "^4.0.3"

glob-to-regexp@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
Expand Down

0 comments on commit ed9728a

Please sign in to comment.