1 Star 0 Fork 438

ryvius_key/element-plus

forked from element-plus/element-plus 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build-locale.js 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
Simona 提交于 2020-11-10 14:24 . build: optimize (#560)
/* eslint-disable */
const fs = require('fs')
const save = require('file-save')
const { resolve, basename } = require('path')
const localePath = resolve(__dirname, '../packages/locale/lang')
const fileList = fs.readdirSync(localePath)
const transform = function(filename, name, cb) {
require('@babel/core').transformFile(resolve(localePath, filename), {
plugins: [
'@babel/plugin-transform-modules-umd',
],
moduleId: name,
}, cb)
}
fileList
.filter(function(file) {
return /\.ts$/.test(file)
})
.forEach(function(file) {
const name = basename(file, '.ts')
transform(file, name, function(err, result) {
if (err) {
console.error(err)
} else {
const code = result.code
const transformedCode = code
.replace('define(\"', 'define(\"element/locale/')
.replace(
/global\.(\S*) = mod.exports/,
'global.ELEMENT.lang = global.ELEMENT.lang || {};\n global.ELEMENT.lang.$1 = mod.exports.default'
)
save(resolve(__dirname, '../lib/umd/locale', `${name}.js`)).write(transformedCode)
}
})
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ryvius_key/element-plus.git
git@gitee.com:ryvius_key/element-plus.git
ryvius_key
element-plus
element-plus
dev

搜索帮助