-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvgo.config.cjs
49 lines (47 loc) · 1.04 KB
/
svgo.config.cjs
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
/**
* @function generateRandomString
* @description Generate a random string of a given length.
*
* @param {number} length
* @returns {string} Random string
*
* @example
* ```js
* const randomString = generateRandomString(10);
* console.log(randomString); // 'aBcDeFgHiJ'
* ```
*/
const generateRandomString = (length) => {
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
result += characters[randomIndex];
}
return result;
};
/** @type {import('svgo').Config} */
const svgoConfig = {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'convertStyleToAttrs',
'cleanupIds',
{
name: 'prefixIds',
params: {
delim: '',
prefix: () => `svg-${generateRandomString(10)}-`,
},
},
'removeDimensions',
],
};
module.exports = svgoConfig;