-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbabel.config.js
More file actions
52 lines (49 loc) · 1.59 KB
/
babel.config.js
File metadata and controls
52 lines (49 loc) · 1.59 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
const path = require('path')
// eslint-disable-next-line immutable/no-mutation
module.exports = {
presets: [
['@instructure/ui-babel-preset', {
themeable: !process.env.DEBUG && process.env.NODE_ENV !== 'test',
coverage: process.env.NODE_ENV === 'test',
esModules: Boolean(process.env.ES_MODULES)
}],
'@babel/preset-typescript'
],
plugins: [
'inline-react-svg',
['@babel/plugin-transform-private-property-in-object', { 'loose': true }],
['@babel/plugin-proposal-decorators', { 'version': 'legacy' }],
['@babel/plugin-transform-private-methods', { 'loose': true }],
...getFormatMessageConfig(),
...(process.env.TRANSPILE ? [['module-resolver', {
root: ['./src'],
alias: {
'@': './src',
'@components': './src/components',
'@util': './src/util',
'@types': './src/types',
'@hooks': './src/hooks'
}
}]] : [])
]
}
function getFormatMessageConfig () {
const translationsDir = './translations'
let formatMessageConfig = []
// if a BUILD_LOCALE environment variable is set, generate pre-translated source for that language,
const BUILD_LOCALE = process.env.BUILD_LOCALE
if (BUILD_LOCALE) {
formatMessageConfig = [
['transform-format-message', {
generateId: 'underscored_crc32',
inline: true,
locale: BUILD_LOCALE,
translations: {
// eslint-disable-next-line security/detect-non-literal-require
[BUILD_LOCALE]: require(path.join(process.cwd(), translationsDir, BUILD_LOCALE))
}
}]
]
}
return formatMessageConfig
}