diff --git a/packages/plugins/client/build.js b/packages/plugins/client/build.js index 8516ed076..5b9cbf4e3 100644 --- a/packages/plugins/client/build.js +++ b/packages/plugins/client/build.js @@ -20,8 +20,22 @@ exports.run = async (log) => { }); log('coping antd locale'); - await fs.cp(path.resolve(path.dirname(antd)), path.resolve(localeDir, 'antd'), { - recursive: true, - force: true, - }); + const files = await fs.readdir(path.resolve(path.dirname(antd), 'locale')); + await fs.mkdir(path.resolve(localeDir, 'antd'), { force: true, recursive: true }); + for (const file of files) { + if (path.extname(file) !== '.js') { + continue; + } + const content = require(path.resolve(path.dirname(antd), 'locale', file)).default; + try { + await fs.writeFile( + path.resolve(localeDir, 'antd', file), + `module.exports = ${JSON.stringify(content)}`, + 'utf-8', + {}, + ); + } catch (error) { + log(`skip ${file}`); + } + } }; diff --git a/packages/plugins/client/src/server/antd.ts b/packages/plugins/client/src/server/antd.ts index 1b3e4b15d..190c249d5 100644 --- a/packages/plugins/client/src/server/antd.ts +++ b/packages/plugins/client/src/server/antd.ts @@ -3,7 +3,7 @@ import { resolve } from 'path'; export const getAntdLocale = (lang) => { const lng = lang.replace('-', '_'); - const files = [resolve(__dirname, `./../locale/antd/locale/${lng}`)]; + const files = [resolve(__dirname, `../locale/antd/${lng}`)]; if (process.env.APP_ENV !== 'production') { files.unshift(`antd/lib/locale/${lng}`); files.push(`antd/lib/locale/en_US`);