![](/img/trans.png)
[英]How to include JavaScript libraries only in production build files of create-react-app?
[英]Is there a way for me to include the React production build files without using Express?
我想在我的庫中包含 React,但我不知道該怎么做。 使用 HTTP 模塊,有沒有辦法可以遞歸發送 static 文件? 我想發送 React 生產構建的build
文件夾,但我不知道如何發送所有文件。
實際上,我已經找到了解決方案。 你能做的是
var fs = require('fs'),
http = require('http');
http.createServer(function (req, res) {
fs.readFile(__dirname + req.url, function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
res.writeHead(200);
res.end(data);
});
}).listen(8080);```
and serve static files using that way, or you can use the node-static module.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.