forked from discretize/discretize-gear-optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel-extract-en.config.js
135 lines (133 loc) · 5.06 KB
/
babel-extract-en.config.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* eslint-disable import/extensions */
const YAML = require('js-yaml');
const fs = require('fs');
const { requireTS } = require('./src/utils/require-ts.js');
const { GEAR_SLOTS, Affix } = requireTS('./src/utils/gw2-data.ts');
const templates = YAML.load(fs.readFileSync('./src/assets/presetdata/templates.yaml', 'utf8'));
const presets = {
trait: YAML.load(fs.readFileSync('./src/assets/presetdata/preset-traits.yaml', 'utf8')),
affix: YAML.load(fs.readFileSync('./src/assets/presetdata/preset-affixes.yaml', 'utf8')),
distribution: YAML.load(
fs.readFileSync('./src/assets/presetdata/preset-distribution.yaml', 'utf8'),
),
buff: YAML.load(fs.readFileSync('./src/assets/presetdata/preset-buffs.yaml', 'utf8')),
infusion: YAML.load(fs.readFileSync('./src/assets/presetdata/preset-infusions.yaml', 'utf8')),
extra: YAML.load(fs.readFileSync('./src/assets/presetdata/preset-extras.yaml', 'utf8')),
};
const buffs = YAML.load(fs.readFileSync('./src/assets/modifierdata/buffs.yaml', 'utf8'));
const professions = {
elementalist: YAML.load(fs.readFileSync('./src/assets/modifierdata/elementalist.yaml', 'utf8')),
engineer: YAML.load(fs.readFileSync('./src/assets/modifierdata/engineer.yaml', 'utf8')),
guardian: YAML.load(fs.readFileSync('./src/assets/modifierdata/guardian.yaml', 'utf8')),
mesmer: YAML.load(fs.readFileSync('./src/assets/modifierdata/mesmer.yaml', 'utf8')),
necromancer: YAML.load(fs.readFileSync('./src/assets/modifierdata/necromancer.yaml', 'utf8')),
ranger: YAML.load(fs.readFileSync('./src/assets/modifierdata/ranger.yaml', 'utf8')),
revenant: YAML.load(fs.readFileSync('./src/assets/modifierdata/revenant.yaml', 'utf8')),
thief: YAML.load(fs.readFileSync('./src/assets/modifierdata/thief.yaml', 'utf8')),
warrior: YAML.load(fs.readFileSync('./src/assets/modifierdata/warrior.yaml', 'utf8')),
};
const extra = {
sigils: YAML.load(fs.readFileSync('./src/assets/modifierdata/sigils.yaml', 'utf8')),
runes: YAML.load(fs.readFileSync('./src/assets/modifierdata/runes.yaml', 'utf8')),
food: YAML.load(fs.readFileSync('./src/assets/modifierdata/food.yaml', 'utf8')),
utility: YAML.load(fs.readFileSync('./src/assets/modifierdata/utility.yaml', 'utf8')),
};
module.exports = {
presets: ['@babel/preset-typescript', '@babel/preset-react'],
plugins: [
[
'./extract_context_injection',
{
buildTemplateName: [
...new Set(templates.list.flatMap((item) => item.builds).map((item) => item.name)),
],
presetName: [
...new Set(
Object.entries(presets).flatMap((entry) =>
entry[1].list.map((item) => `${entry[0]}_${item.name}`),
),
),
],
buffSection: [...new Set(buffs.map((item) => item.section))],
buffText: [...new Set(buffs.flatMap((item) => item.items).map((item) => item.text))],
amountLabel: [
...new Set([
...Object.values(professions)
.flat()
.flatMap((item) => item.items)
.map((item) => item?.amountData?.label)
.filter((item) => item),
...Object.values(extra)
.flat()
.flatMap((section) => section.items)
.map((item) => item?.amountData?.label)
.filter((item) => item),
]),
'x',
],
skillSubText: [
...new Set(
Object.values(professions)
.flat()
.filter((item) => item.section === 'Skills')
.flatMap((item) => item.items)
.filter((item) => item.subText)
.map((item) => item.subText),
),
],
extraSection: [
...new Set(
Object.values(extra)
.flat()
.flatMap((item) => item.section),
),
],
extraSubText: [
...new Set(
Object.values(extra)
.flat()
.flatMap((section) => section.items)
.map((item) => item.subText)
.filter((item) => item),
),
'',
],
traitSubText: [
...new Set(
Object.values(professions)
.flat()
.filter((item) => item.section !== 'Skills')
.flatMap((item) => item.items)
.filter((item) => item.subText)
.map((item) => item.subText),
),
'',
],
traitNote: [
...new Set(
Object.values(professions)
.flat()
.flatMap((item) => item.note)
.filter(Boolean),
),
'',
],
slotName: [...new Set(Object.values(GEAR_SLOTS).map((item) => item.name))],
affix: Object.keys(Affix),
},
],
[
'i18next-extract',
{
locales: ['en'],
keySeparator: null,
nsSeparator: null,
keyAsDefaultValue: ['en'],
useI18nextDefaultValue: ['en'],
discardOldKeys: true,
outputPath: 'locales/{{locale}}/{{ns}}.json',
customTransComponents: [['react-i18next', 'Trans']],
},
],
],
};