-
Notifications
You must be signed in to change notification settings - Fork 7
/
arui-scripts.overrides.ts
81 lines (68 loc) · 2.87 KB
/
arui-scripts.overrides.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// TODO: remove eslint-disable-next-line
import { OverrideFile } from 'arui-scripts';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import path from 'node:path';
// eslint-disable-next-line import/no-extraneous-dependencies
import {RuleSetRule} from 'webpack';
const overrides: OverrideFile = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
webpackClient: (config, appConfig, { createSingleClientWebpackConfig, findLoader }) => {
const workerConfig = createSingleClientWebpackConfig(
{ worker: './src/worker.ts' },
'worker',
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
workerConfig.output.filename = 'worker.js';
const rootConfigList = Array.isArray(config) ? config : [config];
// Делаем стабильные имена классов css модулей для тестирования
// eslint-disable-next-line no-restricted-syntax
for (const rootConfig of rootConfigList) {
const cssModulesLoader = findLoader(rootConfig, '/\\.module\\.css$/');
if (cssModulesLoader?.use && Array.isArray(cssModulesLoader.use)) {
const cssLoader = cssModulesLoader.use.find((loader) => {
// без длинной проверки ts ругается
if (loader && typeof loader === 'object' && ('loader' in loader) && typeof loader.loader === 'string') {
return loader.loader.includes('css-loader') && !loader.loader.includes('postcss-loader')
}
return false
}) as RuleSetRule;
if (typeof cssLoader?.options === 'object') {
cssLoader.options.modules = {
localIdentName: '[name]-[local]-[hash:base64:5]'
}
}
}
}
return [
...rootConfigList,
workerConfig,
];
},
webpackClientProd: (config) => {
const allConfigs = Array.isArray(config) ? config : [config];
return allConfigs.map((config) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line no-param-reassign
config.optimization.minimize = false;
return config;
});
},
postcss: (config) => {
const overridesConfig = config
.map(name => {
if (name !== 'postcss-mixins') return name;
return [
name,
{
mixinsFiles: [path.join(process.cwd(), '../../node_modules/@alfalab/core-components/vars/typography.css')]
}
]
})
return overridesConfig;
}
};
export default overrides;