如何 - 监视未压缩的文件(没有Webpack)

时间:2017-08-16 10:11:14

标签: node.js angular express

我已经编写了代码,它是由webpack构建的/ dist,用于开发,等待在dist /文件夹中更新/构建并从中获取结果。有很好的“webpack-dev-server --port = 4200”命令,但我有快递.JS。如何在运行项目后快速更新结果。也许它可以通过webpack来实现:

/////////////////////package.json
"scripts": {
    "ng": "ng",
    "dev": "concurrently nodemon ./src/index.ts \"tsc -w -p ./src\" ",
    "start": "ng build && concurrently nodemon ./src/index.ts \"tsc -w -p ./src\" ",
    "build": "ng build --watch",
    "build:watch": "\"tsc -w -p ./src\"",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },

//////////////////////index.ts
import * as express from 'express';
import { join } from 'path';
import { json, urlencoded }from 'body-parser';

var app : any = express();

app.use(express.static(join(__dirname + '/../dist')));
app.use(json());
app.use(urlencoded({
	extended: true
}));

app.get('*', function(req, res, next) {
	res.sendFile(join(__dirname + '/../dist/index.html'));
});

console.log('3000!! ', 3000);
app.listen(process.env.PORT || 3000);

我尝试过包含./src文件夹 - app.use(express.static(resolve(__ dirname,'.. / src'))); res.sendFile(resolve(__ dirname,'.. / src / index.html'));但它不起作用:

请帮助

packaje.json
dist
assets
src - app
    - index.html
    - index.ts

0 个答案:

没有答案