Node.js 部署到Heroku时如何丑化/缩小Angular应用程序
我正在尝试缩小应用程序中的所有.js和.css文件 1。我已经做的:Node.js 部署到Heroku时如何丑化/缩小Angular应用程序,node.js,heroku,Node.js,Heroku,我正在尝试缩小应用程序中的所有.js和.css文件 1。我已经做的: server.js const path = require('path'); const express = require('express'); const app = express(); // Serve static files app.use(express.static(__dirname + '/dist/my_app')); // Send all requests to index.html app.
server.js
const path = require('path');
const express = require('express');
const app = express();
// Serve static files
app.use(express.static(__dirname + '/dist/my_app'));
// Send all requests to index.html
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/my_app/index.html'));
});
// default Heroku port
app.listen(process.env.PORT || 5000);
2。在package.json上设置start
和postinstall
"start": "node server.js"
"postinstall": "ng build --aot --prod"
然后我将我的应用程序部署到Herokuapp。这些文件中未应用“丑陋”和“缩小”
<body data-spy="scroll" data-offset="1">
<app-root></app-root>
<script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="scripts.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body>
事实证明,此链接对ReactJs应用程序最有帮助。这个链接对ReactJs应用程序最有帮助。