React丨Umi3.x 启动后自动打开浏览器
自己弄,解决方案:
- 安装插件
cnpm i open-browser-webpack-plugin -D
.umirc.ts
import { defineConfig } from 'umi';
export default defineConfig({
chainWebpack(memo, { env, webpack, craeteCSSRule }) {
env === 'development'
? memo
.plugin('open-browser-webpack-plugin')
.use('open-browser-webpack-plugin', [{ url: 'http://localhost:8000' }])
: ''; // 此处URL与项目启动的URL保持一致
},
nodeModulesTransform: {
type: 'none',
},
routes: [
{ path: '/', component: '@/pages/index' },
],
fastRefresh: {},
});