08c5383bee
* refactor: core/build and cli/build.js * fix: build * fix: bug * fix: replaceAll to replace * fix: node version check * fix: add require check * fix: esbuild other ext * fix: process json * fix: exlude jsx-runtime * feat: split chunk * fix: minify plugin client bundle * fix: compatibility * fix: support import() * feat: update docs * fix: server deps * feat: demo * fix: remove cjs treeshake * fix: local error * fix: bug * fix: lazy load * fix: rewrites * fix: remove dynamic import function * feat: doc demo * fix: codesanbox vite template * fix: codesanbox demo * fix: hide stackblitz * fix: revert rspack * fix: test bug * fix: delete console * fix: import dayjs locale --------- Co-authored-by: chenos <chenlinxh@gmail.com>
71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
import { getUmiConfig, IndexGenerator } from '@nocobase/devtools/umiConfig';
|
|
import path from 'path';
|
|
import { defineConfig } from 'umi';
|
|
|
|
const umiConfig = getUmiConfig();
|
|
|
|
process.env.MFSU_AD = 'none';
|
|
process.env.DID_YOU_KNOW = 'none';
|
|
|
|
const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉
|
|
|
|
const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/')
|
|
.split(',').map(item => path.join(__dirname, '..', '..', '..', '..', item));
|
|
|
|
const outputPluginPath = path.join(__dirname, 'src', '.plugins');
|
|
const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs);
|
|
indexGenerator.generate();
|
|
|
|
export default defineConfig({
|
|
title: 'Loading...',
|
|
favicons: ['/favicon/favicon.ico'],
|
|
metas: [{ name: 'viewport', content: 'initial-scale=0.1' }],
|
|
links: [
|
|
{ rel: 'apple-touch-icon', size: '180x180', ref: '/favicon/apple-touch-icon.png' },
|
|
{ rel: 'icon', type: 'image/png', size: '32x32', ref: '/favicon/favicon-32x32.png' },
|
|
{ rel: 'icon', type: 'image/png', size: '16x16', ref: '/favicon/favicon-16x16.png' },
|
|
{ rel: 'manifest', href: '/favicon/site.webmanifest' },
|
|
{ rel: 'stylesheet', href: '/global.css' },
|
|
],
|
|
headScripts: ['/browser-checker.js'],
|
|
outputPath: path.resolve(__dirname, '../dist/client'),
|
|
hash: true,
|
|
alias: {
|
|
...umiConfig.alias,
|
|
},
|
|
define: {
|
|
...umiConfig.define,
|
|
'process.env.USE_REMOTE_PLUGIN': process.env.USE_REMOTE_PLUGIN,
|
|
},
|
|
proxy: {
|
|
...umiConfig.proxy,
|
|
},
|
|
fastRefresh: false, // 热更新会导致 Context 丢失,不开启
|
|
mfsu: false,
|
|
esbuildMinifyIIFE: true,
|
|
// srcTranspiler: 'esbuild', // 不行,各种报错
|
|
// mfsu: {
|
|
// esbuild: true // 不行,各种报错
|
|
// },
|
|
// 浏览器兼容性,兼容到 2018 年的浏览器
|
|
targets: {
|
|
chrome: 69,
|
|
edge: 79,
|
|
safari: 12,
|
|
},
|
|
codeSplitting: {
|
|
jsStrategy: 'depPerChunk'
|
|
},
|
|
chainWebpack(config, { env }) {
|
|
if (env === 'production') {
|
|
config.plugin('ignore nocobase plugins').use(require('webpack').IgnorePlugin, [
|
|
{
|
|
resourceRegExp: new RegExp(pluginPrefix.join('|')),
|
|
},
|
|
]);
|
|
}
|
|
return config;
|
|
},
|
|
routes: [{ path: '/*', component: 'index' }],
|
|
});
|