mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 18:16:31 +00:00
9e5e96b9e4
* fix: client lib require wrapper * fix: bug * fix: add tsconfig.paths.json * fix: collection dir not exists * fix: improve... * fix: update yarn.lock * fix: db.sync * fix: bugs * fix: bugs * fix: bugs * fix: bugs && allow user custom build config * docs: user custom config docs * refactor: custom user build config * fix: bugs * fix: build plugin-client bug --------- Co-authored-by: chenos <chenlinxh@gmail.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
import { defineConfig } from '@nocobase/build';
|
|
|
|
const existsSync = require('fs').existsSync;
|
|
|
|
const client = path.dirname(require.resolve('@nocobase/client/package.json'));
|
|
const antd = require.resolve('antd');
|
|
|
|
export default defineConfig({
|
|
afterBuild: async (log) => {
|
|
const localeDir = path.resolve(__dirname, './dist/locale');
|
|
if (existsSync(localeDir)) {
|
|
await fs.rm(localeDir, { recursive: true });
|
|
}
|
|
|
|
log('coping client locale');
|
|
await fs.cp(path.resolve(client, 'lib', 'locale'), localeDir, {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
|
|
log('coping antd locale');
|
|
const files = await fs.readdir(path.resolve(path.dirname(antd), 'locale'));
|
|
await fs.mkdir(path.resolve(localeDir, 'antd'), { 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}`);
|
|
}
|
|
}
|
|
},
|
|
});
|