我有一个带有 angular(v8.2.9) 通用(v8.1.1) 和 Ivy 的项目。
我使用以下命令构建和运行服务器端。
npm run build:ssr && npm run serve:ssr
构建并成功运行,但是当localhost:4000
在浏览器中输入时,在控制台和服务器中显示白页而没有错误。
当成功进入localhost:4000/index.html
站点加载并正常工作时。
为什么要添加index.html
url ?
{
"name": "amyar24site-ivy",
"version": "1.4.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:ssr": "node dist/server",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"build:client-and-server-bundles": "ng build --prod && ng run amyar24siteIvy:server:production --bundleDependencies all"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.9",
"@angular/common": "~8.2.9",
"@angular/compiler": "~8.2.9",
"@angular/core": "~8.2.9",
"@angular/forms": "~8.2.9",
"@angular/http": "~7.2.15",
"@angular/platform-browser": "~8.2.9",
"@angular/platform-browser-dynamic": "~8.2.9",
"@angular/platform-server": "~8.2.9",
"@angular/router": "~8.2.9",
"@fortawesome/fontawesome-free": "5.11.2",
"@ng-select/ng-select": "^3.0.7",
"@nguniversal/express-engine": "^8.1.1",
"@nguniversal/module-map-ngfactory-loader": "^8.1.1",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"bootstrap": "^4.3.1",
"compression": "^1.7.4",
"core-js": "^3.2.1",
"express": "^4.17.1",
"hover.css": "^2.3.2",
"intersection-observer": "^0.7.0",
"memory-cache": "^0.2.0",
"moment": "2.24.0",
"moment-jalaali": "0.8.3",
"ng-circle-progress": "^1.5.1",
"ng-in-viewport": "^6.0.3",
"ng-lazyload-image": "^6.1.0",
"ngx-bootstrap": "^5.2.0",
"ngx-cookie-service": "^2.2.0",
"ngx-device-detector": "^1.3.11",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.8",
"@angular/cli": "~8.3.8",
"@angular/compiler-cli": "~8.2.9",
"@angular/language-service": "~8.2.9",
"@types/node": "~12.7.12",
"@types/jasmine": "~3.4.2",
"@types/jasminewd2": "~2.0.8",
"codelyzer": "~5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-loader": "^6.2.0",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "~3.5.3",
"webpack-cli": "^3.3.9"
}
}