我使用express和typescript。我使用了很多express工具栏。但是,我注意到,当用tsc编译时,views文件夹没有复制到dist文件夹。
在SRC目录我有意见,其中包含两个其他目录包含hbs文件:
|
└── src
└── views
└── emails
└── invitation-email.hbs
字符串
我的主机提供商被配置为加载dist文件夹,该文件夹应包含所有文件夹,包括未在DIST文件夹中复制的视图和公用文件夹.
下面是我的json包:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "jest",
"dev": "nodemon src/server.ts",
"build": "tsc -p tsconfig.json",
"start": "npm run build && node dist/server.js",
"clean": "rimraf dist"
},
"keywords": [],
"author": "Daniel mihai",
"license": "ISC",
"dependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/express": "^4.17.21",
"@types/handlebars": "^4.1.0",
"@types/mongoose": "^5.11.97",
"@types/node": "^20.10.5",
"@types/nodemailer": "^6.4.14",
"bcryptjs": "^2.4.3",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"express-handlebars": "^7.1.2",
"handlebars": "^4.7.8",
"hbs": "^4.2.0",
"mongoose": "^8.0.3",
"nodemailer": "^6.9.8",
"nodemon": "^3.0.2"
},
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/supertest": "^6.0.2",
"jest": "^29.7.0",
"mongodb-memory-server": "^9.1.3",
"rimraf": "^5.0.5",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
型
我的tsl.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src/**/*"] // Adjust the 'include' pattern to match your source files
}
型
100d1x
的字符串
1条答案
按热度按时间hzbexzde1#
tsc
只将typescript构建到dist文件夹中。看看npm copyFiles。
您的
build
命令将类似于下面的"build": "tsc -p tsconfig.json && copyfiles src/views dist/views && copyfiles src/public dist/public"