我正在服务器端渲染的 React 中开发一个名为“主题”的本地 npm 包,node.js 应用程序名为 cezerin( https://github.com/cezerin/cezerin/issues/560 )。
目前它正在与 pm2 一起运行,包括 api、店面,并且它正在监视本地包主题中的文件更改。但是,当我通过更改主题中的代码来更改外观时,它不会自动重新启动服务器。
{
"apps": [
{
"name": "api",
"cwd": "./src/api/server",
"args": [],
"script": "index.js",
"node_args":"cross-env NODE_ENV=development",
"watch": ["./config/server.js", "./src/api/server/"],
"instances": "1",
"exec_mode": "fork",
"watch_options": {
"persistent": true,
"ignoreInitial": false
}
},
{
"name": "store",
"cwd": "./src/store/server",
"args": [],
"script": "index.js",
"node_args":"cross-env NODE_ENV=development",
"watch": [
"./config/server.js",
"./store/",
"./theme/",
"./theme/assets/index.html"
],
"instances": "1",
"exec_mode": "fork",
"watch_options": {
"persistent": true,
"ignoreInitial": false
}
}
]
}
当你想在你正在开发的本地主题中更改代码时立即看到变化时,大家如何设置开发模式?
最佳答案
您需要使用“观看”选项运行 cezerin 应用程序。
npm run build:watch
默认情况下,cezerin2 支持观察者。
github.com/cezerin2
使用“观看”选项,所有更改或您的更改在浏览器重新加载页面后可用。
如果您看不到更改,请尝试在 chrome 开发控制台 - 应用程序 - Service Wroker - 取消注册并重新加载页面中清除 Service Worker。
关于node.js - 如何热模块替换我在服务器端渲染的 React、node.js 应用程序中开发的本地 npm 包,例如在 cezerin 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54247091/