umi3解决开发时编译慢

33 阅读1分钟

1.新建一个watch-route.js

nodemon = require('nodemon');
const path =require('path');
const watchFile1 = path.resolve(__dirname, './config/routes.ts');
const watchFile2 = path.resolve(__dirname, './config/proxy.ts');

nodemon({
    watch: [watchFile1,watchFile2],
    ext: '.ts',
    exec: 'cross-env WATCH=none NODE_OPTIONS=--max_old_space_size=4096 REACT_APP_ENV=dev  PORT=8000 UMI_ENV=dev umi dev'
}).on('start',()=>{
    console.log('start')
}).on('restart',()=>{
    console.log('end');
})

2. package.json script

{
    "scripts": {
        "dev": "node watch-route.js"
    }
}