-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy patharui-scripts.overrides.ts
More file actions
79 lines (68 loc) · 2.75 KB
/
Copy patharui-scripts.overrides.ts
File metadata and controls
79 lines (68 loc) · 2.75 KB
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
// TODO: remove eslint-disable and eslint-disable-next-line
/* eslint-disable no-param-reassign */
import { type 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 { type RuleSetRule } from 'webpack';
const overrides: OverrideFile = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
webpackClient: (config, appConfig, { findLoader }) => {
const allConfigs = Array.isArray(config) ? config : [config];
// Делаем стабильные имена классов css модулей для тестирования
// eslint-disable-next-line no-restricted-syntax
for (const singleConfig of allConfigs) {
const cssModulesLoader = findLoader(singleConfig, '/\\.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 allConfigs;
},
webpackClientProd: (config) => {
const allConfigs = Array.isArray(config) ? config : [config];
return allConfigs.map((singleConfig) => {
singleConfig.optimization.minimize = false;
return singleConfig;
});
},
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;