-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.dumirc.ts
160 lines (147 loc) · 4.43 KB
/
.dumirc.ts
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import chalk from 'chalk';
import { defineConfig } from 'dumi';
import type { SiteThemeConfig } from 'dumi-theme-antd-style';
import { readdirSync } from 'fs';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import { join } from 'path';
const { TamaguiPlugin } = require('tamagui-loader');
// more example about dumi https://github.com/thundersdata-frontend/td-design
// https://github.com/ant-design/pro-components/blob/master/.dumirc.ts
// @ts-ignore
import { homepage, name } from './package.json';
const isProd = process.env.NODE_ENV === 'production';
const headPkgList: string[] = [];
// utils must build before core
// runtime must build before renderer-react
const pkgList = readdirSync(join(__dirname, 'packages')).filter(
(pkg) => pkg.charAt(0) !== '.' && !headPkgList.includes(pkg),
);
const exampleList = readdirSync(join(__dirname, 'example')).filter(
(pkg) => pkg.charAt(0) !== '.' && !headPkgList.includes(pkg),
);
const tailPkgList = pkgList.map((path) => {
return {
src: `packages/${path}/src/`,
path,
};
});
const examplePkgList = exampleList.map((path) => {
return {
src: `example/${path}/src/`,
path,
};
});
const alias = pkgList.reduce(
(pre, pkg) => {
pre[`@next-dev/${pkg}`] = join(__dirname, 'packages', pkg, 'src');
return {
...pre,
};
},
{} as Record<string, string>,
);
console.log(`🌼 alias list \n${chalk.blue(Object.keys(alias).join('\n'))}`);
// console.log('tailPkgList', pkgList)
const themeConfig: SiteThemeConfig = {
name: 'Next Dev',
// logo: 'https://gw.alipayobjects.com/zos/hitu-asset/c88e3678-6900-4289-8538-31367c2d30f2/hitu-1609235995955-image.png',
socialLinks: { github: homepage },
apiHeader: {
pkg: name,
sourceUrl: `{github}/tree/master/src/components/{atomId}/index.tsx`,
docUrl: `{github}/tree/master/example/docs/components/{atomId}.{locale}.md`,
},
footer: 'Made with ❤️ by Next Dev',
};
export default defineConfig({
proxy: {
'/backend-api/v2': {
target: '',
changeOrigin: true,
pathRewrite: { '^/backend-api/v2': '/backend-api/v2' },
},
},
plugins: [require.resolve('@umijs/plugins/dist/tailwindcss')],
tailwindcss: {},
themeConfig: {
hd: { rules: [] },
...themeConfig,
// nav: [{ title: 'Docs', link: '/packages/utils' }],
},
// html2sketch: {},
favicons: [
'https://gw.alipayobjects.com/zos/hitu-asset/c88e3678-6900-4289-8538-31367c2d30f2/hitu-1609235995955-image.png',
],
locales: [
{ id: 'en-US', name: 'English' },
// { id: 'zh-CN', name: '中文' },
],
alias,
styles: [
`html, body { background: transparent; }
@media (prefers-color-scheme: dark) {
html, body { background: #0E1116; }
}`,
],
extraBabelPlugins: ['antd-style'],
codeSplitting: {
jsStrategy: 'granularChunks',
},
fastRefresh: true,
ssr: false,
exportStatic: {},
mfsu: {
exclude: ['dumi-theme-antd-style', /dumi/, '@ant-design/cssinjs'],
shared: {
react: {
singleton: true,
},
},
},
// mfsu: false,
resolve: {
// Configure the entry file path, API parsing will start from here
// entryFile: './packages/utils/src/index.ts',
// auto generate docs
atomDirs: [
...tailPkgList.map(({ src, path }) => ({
type: path,
dir: src,
})),
...examplePkgList.map(({ src, path }) => ({
type: path,
dir: src,
})),
],
},
npmClient: 'yarn',
chainWebpack(config, { webpack }) {
config.plugin('monaco-editor').use(MonacoWebpackPlugin);
config.resolve.alias.batch(() => {
return {
'react-native': 'react-native-web-lite',
'react-native-svg': '@tamagui/react-native-svg',
'@expo/vector-icons': '@tamagui/proxy-worm',
};
});
// Add the new TamaguiPlugin to the plugins array
config.plugin('provide').use(
new TamaguiPlugin({
// config: './tamagui.config.ts',
components: [],
importsWhitelist: ['constants.js', 'colors.js'],
logTimings: true,
disableExtraction: process.env.NODE_ENV === 'development',
}),
);
config.resolve.extensions.batch(() => ['demo.tsx']);
config.plugin('$global').use(
// https://webpack.js.org/plugins/provide-plugin/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
__DEV__: process.env.NODE_ENV !== 'production' || true,
}),
);
return config;
},
});