Skip to content

Commit 352c071

Browse files
committed
#CR-10 - Move to vite
1 parent 7689f9c commit 352c071

File tree

184 files changed

+4093
-2836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+4093
-2836
lines changed

configs/webpack.config.renderer.dev.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ const configuration: webpack.Configuration = {
7676
plugins: [require.resolve('react-refresh/babel')].filter(Boolean),
7777
},
7878
},
79+
{
80+
loader: 'string-replace-loader',
81+
options: {
82+
search: /import (\w+) from '(.+?)\.svg\?react'/g,
83+
replace: "import { ReactComponent as $1 } from '$2.svg'",
84+
},
85+
}
7986
],
8087
},
8188
{
@@ -95,6 +102,10 @@ const configuration: webpack.Configuration = {
95102
loader: 'sass-loader',
96103
options: {
97104
sourceMap: true,
105+
additionalData: `
106+
@use "uiSrc/styles/mixins/_eui.scss";
107+
@use "uiSrc/styles/mixins/_global.scss";
108+
`
98109
},
99110
},
100111
],
@@ -113,6 +124,10 @@ const configuration: webpack.Configuration = {
113124
loader: 'sass-loader',
114125
options: {
115126
sourceMap: true,
127+
additionalData: `
128+
@use "uiSrc/styles/mixins/_eui.scss";
129+
@use "uiSrc/styles/mixins/_global.scss";
130+
`
116131
},
117132
},
118133
],

configs/webpack.config.renderer.prod.ts

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,60 +44,77 @@ const configuration: webpack.Configuration = {
4444
module: {
4545
rules: [
4646
{
47-
test: /\.module\.s(a|c)ss$/,
47+
test: /\.[jt]sx?$/,
48+
exclude: /node_modules/,
4849
use: [
4950
{
50-
loader: MiniCssExtractPlugin.loader,
51-
},
52-
{
53-
loader: 'css-loader',
51+
loader: 'babel-loader',
5452
options: {
55-
modules: true,
56-
sourceMap: false,
53+
cacheDirectory: false,
5754
},
5855
},
5956
{
60-
loader: 'sass-loader',
57+
loader: 'string-replace-loader',
6158
options: {
62-
sourceMap: false,
59+
search: /import (\w+) from '(.+?)\.svg\?react'/g,
60+
replace: "import { ReactComponent as $1 } from '$2.svg'",
6361
},
64-
},
62+
}
6563
],
6664
},
6765
{
68-
test: /\.s(a|c)ss$/,
69-
exclude: [/\.module.(s(a|c)ss)$/, /\.lazy\.s(a|c)ss$/i],
66+
test: /\.module\.s(a|c)ss$/,
7067
use: [
7168
{
7269
loader: MiniCssExtractPlugin.loader,
7370
},
7471
{
7572
loader: 'css-loader',
73+
options: {
74+
modules: true,
75+
sourceMap: false,
76+
},
7677
},
7778
{
7879
loader: 'sass-loader',
7980
options: {
8081
sourceMap: false,
82+
additionalData: `
83+
@use "uiSrc/styles/mixins/_eui.scss";
84+
@use "uiSrc/styles/mixins/_global.scss";
85+
`
8186
},
8287
},
8388
],
8489
},
85-
// SASS lazy support
8690
{
87-
test: /\.lazy\.s(a|c)ss$/i,
91+
test: /\/(dark|light)Theme.scss/,
92+
use: [
93+
'raw-loader',
94+
'sass-loader',
95+
]
96+
},
97+
{
98+
test: /\.s(a|c)ss$/,
99+
exclude: [/\.module.(s(a|c)ss)$/, /\/(dark|light)Theme.scss/],
88100
use: [
89101
{
90-
loader: 'style-loader',
91-
options: { injectType: 'lazySingletonStyleTag' },
102+
loader: MiniCssExtractPlugin.loader,
92103
},
93104
{
94105
loader: 'css-loader',
95106
},
96107
{
97108
loader: 'sass-loader',
109+
options: {
110+
sourceMap: false,
111+
additionalData: `
112+
@use "uiSrc/styles/mixins/_eui.scss";
113+
@use "uiSrc/styles/mixins/_global.scss";
114+
`
115+
},
98116
},
99117
],
100-
exclude: /node_modules/,
101118
},
102119
{
103120
test: /\.css$/,
@@ -217,6 +234,9 @@ const configuration: webpack.Configuration = {
217234
'process.env.RI_SEGMENT_WRITE_KEY': 'RI_SEGMENT_WRITE_KEY' in process.env
218235
? JSON.stringify(process.env.RI_SEGMENT_WRITE_KEY)
219236
: JSON.stringify('SOURCE_WRITE_KEY'),
237+
'process.env.NODE_DEBUG': 'NODE_DEBUG' in process.env
238+
? JSON.stringify(process.env.NODE_DEBUG)
239+
: JSON.stringify(''),
220240
}),
221241
],
222242
};

configs/webpack.config.web.common.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ export default {
2424
webpackPaths.apiPath,
2525
webpackPaths.desktopPath,
2626
],
27-
use: {
28-
loader: 'babel-loader',
29-
options: {
30-
cacheDirectory: true,
27+
use: [
28+
{
29+
loader: 'babel-loader',
30+
options: {
31+
cacheDirectory: true,
32+
},
3133
},
32-
},
34+
{
35+
loader: 'string-replace-loader',
36+
options: {
37+
search: /import (\w+) from '(.+?)\.svg\?react'/g,
38+
replace: "import { ReactComponent as $1 } from '$2.svg'",
39+
},
40+
},
41+
]
3342
},
3443
{
3544
test: /\.svg$/,
@@ -43,6 +52,18 @@ export default {
4352
],
4453
},
4554

55+
ignoreWarnings: [
56+
{
57+
module: /elastic.scss/,
58+
},
59+
{
60+
module: /QueryCardHeader/,
61+
},
62+
{
63+
module: /\/(dark|light)Theme.scss/,
64+
},
65+
],
66+
4667
context: webpackPaths.uiPath,
4768

4869
/**

configs/webpack.config.web.dev.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,24 @@ const configuration: webpack.Configuration = {
7979
loader: 'sass-loader',
8080
options: {
8181
sourceMap: true,
82+
additionalData: `
83+
@use "uiSrc/styles/mixins/_eui.scss";
84+
@use "uiSrc/styles/mixins/_global.scss";
85+
`
8286
},
8387
},
8488
],
8589
},
90+
{
91+
test: /\/(dark|light)Theme.scss/,
92+
use: [
93+
'raw-loader',
94+
'sass-loader',
95+
]
96+
},
8697
{
8798
test: /\.s(a|c)ss$/,
88-
exclude: [/\.module.(s(a|c)ss)$/, /\.lazy\.s(a|c)ss$/i],
99+
exclude: [/\.module.(s(a|c)ss)$/, /\.lazy\.s(a|c)ss$/i, /\/(dark|light)Theme.scss/],
89100
use: [
90101
{
91102
loader: 'style-loader',
@@ -97,26 +108,14 @@ const configuration: webpack.Configuration = {
97108
loader: 'sass-loader',
98109
options: {
99110
sourceMap: true,
111+
additionalData: `
112+
@use "uiSrc/styles/mixins/_eui.scss";
113+
@use "uiSrc/styles/mixins/_global.scss";
114+
`
100115
},
101116
},
102117
],
103118
},
104-
{
105-
test: /\.lazy\.s(a|c)ss$/i,
106-
use: employCache([
107-
{
108-
loader: 'style-loader',
109-
options: { injectType: 'lazySingletonStyleTag' },
110-
},
111-
{
112-
loader: 'css-loader',
113-
},
114-
{
115-
loader: 'sass-loader',
116-
},
117-
]),
118-
exclude: /node_modules/,
119-
},
120119
{
121120
test: /\.css$/,
122121
use: ['style-loader', 'css-loader'],
@@ -231,6 +230,7 @@ const configuration: webpack.Configuration = {
231230
RI_CONNECTIONS_TIMEOUT_DEFAULT: 'RI_CONNECTIONS_TIMEOUT_DEFAULT' in process.env
232231
? process.env.RI_CONNECTIONS_TIMEOUT_DEFAULT
233232
: toString(30 * 1000),
233+
NODE_DEBUG: 'NODE_DEBUG' in process.env ? process.env.NODE_DEBUG : '',
234234
}),
235235

236236
new webpack.LoaderOptionsPlugin({

configs/webpack.config.web.prod.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const configuration: webpack.Configuration = {
9393
RI_CONNECTIONS_TIMEOUT_DEFAULT: 'RI_CONNECTIONS_TIMEOUT_DEFAULT' in process.env
9494
? process.env.RI_CONNECTIONS_TIMEOUT_DEFAULT
9595
: toString(30 * 1000), // 30 sec
96+
NODE_DEBUG: 'NODE_DEBUG' in process.env ? process.env.NODE_DEBUG : '',
9697
}),
9798

9899
new BundleAnalyzerPlugin({
@@ -118,14 +119,25 @@ const configuration: webpack.Configuration = {
118119
{
119120
loader: 'sass-loader',
120121
options: {
121-
sourceMap: false,
122+
sourceMap: true,
123+
additionalData: `
124+
@use "uiSrc/styles/mixins/_eui.scss";
125+
@use "uiSrc/styles/mixins/_global.scss";
126+
`
122127
},
123128
},
124129
],
125130
},
131+
{
132+
test: /\/(dark|light)Theme.scss/,
133+
use: [
134+
'raw-loader',
135+
'sass-loader',
136+
]
137+
},
126138
{
127139
test: /\.s(a|c)ss$/,
128-
exclude: [/\.module.(s(a|c)ss)$/, /\.lazy\.s(a|c)ss$/i],
140+
exclude: [/\.module.(s(a|c)ss)$/, /\.lazy\.s(a|c)ss$/i, /\/(dark|light)Theme.scss/],
129141
use: [
130142
{
131143
loader: MiniCssExtractPlugin.loader,
@@ -136,27 +148,15 @@ const configuration: webpack.Configuration = {
136148
{
137149
loader: 'sass-loader',
138150
options: {
139-
sourceMap: false,
151+
sourceMap: true,
152+
additionalData: `
153+
@use "uiSrc/styles/mixins/_eui.scss";
154+
@use "uiSrc/styles/mixins/_global.scss";
155+
`
140156
},
141157
},
142158
],
143159
},
144-
{
145-
test: /\.lazy\.s(a|c)ss$/i,
146-
use: [
147-
{
148-
loader: 'style-loader',
149-
options: { injectType: 'lazySingletonStyleTag' },
150-
},
151-
{
152-
loader: 'css-loader',
153-
},
154-
{
155-
loader: 'sass-loader',
156-
},
157-
],
158-
exclude: /node_modules/,
159-
},
160160
{
161161
test: /\.css$/,
162162
use: ['style-loader', 'css-loader'],

jest.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
'<rootDir>/redisinsight/__mocks__/fileMock.js',
99
'\\.svg': '<rootDir>/redisinsight/__mocks__/svg.js',
1010
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
11+
'\\.scss\\?inline$': '<rootDir>/redisinsight/__mocks__/scssRaw.js',
1112
'uiSrc/(.*)': '<rootDir>/redisinsight/ui/src/$1',
1213
'monaco-editor': '<rootDir>/redisinsight/__mocks__/monacoMock.js',
1314
unified: '<rootDir>/redisinsight/__mocks__/unified.js',
@@ -22,6 +23,7 @@ module.exports = {
2223
msgpackr: require.resolve('msgpackr'),
2324
},
2425
setupFiles: [
26+
'construct-style-sheets-polyfill',
2527
'<rootDir>/redisinsight/ui/src/setup-env.ts',
2628
],
2729
setupFilesAfterEnv: [

0 commit comments

Comments
 (0)