2023-08-01 16:07:52 +00:00
|
|
|
import { getUmiConfig, IndexGenerator } from '@nocobase/devtools/umiConfig';
|
|
|
|
import path from 'path';
|
2022-02-10 10:37:16 +00:00
|
|
|
import { defineConfig } from 'umi';
|
2022-04-17 09:14:50 +00:00
|
|
|
|
|
|
|
const umiConfig = getUmiConfig();
|
2022-03-06 09:29:20 +00:00
|
|
|
|
2022-02-10 10:37:16 +00:00
|
|
|
process.env.MFSU_AD = 'none';
|
2023-06-20 03:48:02 +00:00
|
|
|
process.env.DID_YOU_KNOW = 'none';
|
2022-02-10 10:37:16 +00:00
|
|
|
|
2023-08-01 16:07:52 +00:00
|
|
|
const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉
|
|
|
|
const pluginDirs = 'packages/plugins/,packages/samples/'.split(',').map((item) => path.join(process.cwd(), item));
|
|
|
|
|
|
|
|
const outputPluginPath = path.join(__dirname, 'src', '.plugins', 'index.ts');
|
|
|
|
const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs);
|
|
|
|
indexGenerator.generate();
|
|
|
|
|
2022-02-10 10:37:16 +00:00
|
|
|
export default defineConfig({
|
2023-06-20 03:48:02 +00:00
|
|
|
title: 'Loading...',
|
|
|
|
favicons: ['/favicon/favicon.ico'],
|
2023-08-01 16:07:52 +00:00
|
|
|
metas: [{ name: 'viewport', content: 'initial-scale=0.1' }],
|
2023-06-20 03:48:02 +00:00
|
|
|
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' },
|
|
|
|
],
|
2023-08-01 16:07:52 +00:00
|
|
|
headScripts: ['/browser-checker.js'],
|
|
|
|
outputPath: path.resolve(__dirname, '../dist/client'),
|
2022-03-21 13:37:35 +00:00
|
|
|
hash: true,
|
2023-06-20 03:48:02 +00:00
|
|
|
alias: {
|
|
|
|
...umiConfig.alias,
|
|
|
|
},
|
2022-03-06 09:29:20 +00:00
|
|
|
define: {
|
|
|
|
...umiConfig.define,
|
2023-08-01 16:07:52 +00:00
|
|
|
'process.env.USE_REMOTE_PLUGIN': process.env.USE_REMOTE_PLUGIN,
|
2022-03-06 09:29:20 +00:00
|
|
|
},
|
|
|
|
proxy: {
|
|
|
|
...umiConfig.proxy,
|
|
|
|
},
|
2023-06-20 03:48:02 +00:00
|
|
|
fastRefresh: false, // 热更新会导致 Context 丢失,不开启
|
|
|
|
mfsu: false,
|
|
|
|
esbuildMinifyIIFE: true,
|
|
|
|
// srcTranspiler: 'esbuild', // 不行,各种报错
|
|
|
|
// mfsu: {
|
|
|
|
// esbuild: true // 不行,各种报错
|
|
|
|
// },
|
|
|
|
// 浏览器兼容性,兼容到 2018 年的浏览器
|
|
|
|
targets: {
|
|
|
|
chrome: 69,
|
|
|
|
edge: 79,
|
|
|
|
safari: 12,
|
2022-02-10 10:37:16 +00:00
|
|
|
},
|
2023-08-01 16:07:52 +00:00
|
|
|
chainWebpack(config, { env }) {
|
|
|
|
if (env === 'production') {
|
|
|
|
config.plugin('ignore nocobase plugins').use(require('webpack').IgnorePlugin, [
|
|
|
|
{
|
|
|
|
resourceRegExp: new RegExp(pluginPrefix.join('|')),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
return config;
|
|
|
|
},
|
2023-06-20 03:48:02 +00:00
|
|
|
routes: [{ path: '/*', component: 'index' }],
|
2022-02-10 10:37:16 +00:00
|
|
|
});
|