Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

typescript - Angular 11 SSR is compiled,but having issue with prod build and serve no content showed up in browser

{

"$schema":"./node_modules/@angular/cli/lib/config/schema.json", "version":1, "newProjectRoot":"projects", "projects":{ "new-asasa":{ "projectType":"application", "schematics":{

     },
     "root":"",
     "sourceRoot":"src",
     "prefix":"app",
     "architect":{
        "build":{
           "builder":"@angular-devkit/build-angular:browser",
           "options":{
              "outputPath":"dist/new-asasa/browser",
              "index":"src/index.html",
              "main":"src/main.ts",
              "polyfills":"src/polyfills.ts",
              "tsConfig":"tsconfig.app.json",
              "aot":true,
              "assets":[
                 "src/favicon.ico",
                 "src/assets"
              ],
              "styles":[
                 "src/styles.scss",
                 "node_modules/intl-tel-input/build/css/intlTelInput.css",
                 "node_modules/ng-zorro-antd/ng-zorro-antd.min.css"
              ],
              "scripts":[
                 "node_modules/intl-tel-input/build/js/intlTelInput.min.js",
                 "node_modules/jquery/dist/jquery.min.js"
              ],
              "allowedCommonJsDependencies":[
                 "rxjs-compat",
                 "lodash"
              ]
           },
           "configurations":{
              "production":{
                 "fileReplacements":[
                    {
                       "replace":"src/environments/environment.ts",
                       "with":"src/environments/environment.prod.ts"
                    }
                 ],
                 "optimization":true,
                 "outputHashing":"all",
                 "sourceMap":false,
                 "namedChunks":false,
                 "extractLicenses":true,
                 "vendorChunk":false,
                 "buildOptimizer":true,
                 "budgets":[
                    {
                       "type":"initial",
                       "maximumWarning":"4mb",
                       "maximumError":"7mb"
                    },
                    {
                       "type":"anyComponentStyle",
                       "maximumWarning":"20kb",
                       "maximumError":"20kb"
                    }
                 ]
              }
           }
        },
        "serve":{
           "builder":"@angular-devkit/build-angular:dev-server",
           "options":{
              "browserTarget":"new-asasa:build"
           },
           "configurations":{
              "production":{
                 "browserTarget":"new-asasa:build:production"
              }
           }
        },
        "extract-i18n":{
           "builder":"@angular-devkit/build-angular:extract-i18n",
           "options":{
              "browserTarget":"new-asasa:build"
           }
        },
        "test":{
           "builder":"@angular-devkit/build-angular:karma",
           "options":{
              "main":"src/test.ts",
              "polyfills":"src/polyfills.ts",
              "tsConfig":"tsconfig.spec.json",
              "karmaConfig":"karma.conf.js",
              "assets":[
                 "src/favicon.ico",
                 "src/assets"
              ],
              "styles":[
                 "src/styles.scss"
              ],
              "scripts":[
                 "node_modules/intl-tel-input/build/js/intlTelInput.min.js"
              ]
           }
        },
        "lint":{
           "builder":"@angular-devkit/build-angular:tslint",
           "options":{
              "tsConfig":[
                 "tsconfig.app.json",
                 "tsconfig.spec.json",
                 "e2e/tsconfig.json",
                 "tsconfig.server.json"
              ],
              "exclude":[
                 "**/node_modules/**"
              ]
           }
        },
        "e2e":{
           "builder":"@angular-devkit/build-angular:protractor",
           "options":{
              "protractorConfig":"e2e/protractor.conf.js",
              "devServerTarget":"new-asasa:serve"
           },
           "configurations":{
              "production":{
                 "devServerTarget":"new-asasa:serve:production"
              }
           }
        },
        "server":{
           "builder":"@angular-devkit/build-angular:server",
           "options":{
              "outputPath":"dist/new-asasa/server",
              "main":"server.ts",
              "tsConfig":"tsconfig.server.json"
           },
           "configurations":{
              "production":{
                 "outputHashing":"media",
                 "fileReplacements":[
                    {
                       "replace":"src/environments/environment.ts",
                       "with":"src/environments/environment.prod.ts"
                    }
                 ],
                 "sourceMap":false,
                 "optimization":true
              }
           }
        },
        "serve-ssr":{
           "builder":"@nguniversal/builders:ssr-dev-server",
           "options":{
              "browserTarget":"new-asasa:build",
              "serverTarget":"new-asasa:server"
           },
           "configurations":{
              "production":{
                 "browserTarget":"new-asasa:build:production",
                 "serverTarget":"new-asasa:server:production"
              }
           }
        },
        "prerender":{
           "builder":"@nguniversal/builders:prerender",
           "options":{
              "browserTarget":"new-asasa:build:production",
              "serverTarget":"new-asasa:server:production",
              "routes":[
                 "/"
              ]
           },
           "configurations":{
              "production":{
                 
              }
           }
        }
     }
  }

}, "defaultProject":"new-asasa", "cli":{ "analytics":false } }

npm run dev:ssr works fine and also show ssr content loaded in browser. but when i run npm run build:ssr && npm run serve:ssr for production build ssr didn't work.

   "dev:ssr": "ng run new-asasa:serve-ssr",
    "serve:ssr": "node dist/new-asasa/server/main.js",
    "build:ssr": "ng build --prod && ng run new-asasa:server:production",
    "prerender": "ng run new-asasa:prerender"    "dev:ssr": "ng run new-asasa:serve-ssr",
    "serve:ssr": "node dist/new-asasa/server/main.js",
    "build:ssr": "ng build --prod && ng run new-asasa:server:production",
    "prerender": "ng run new-asasa:prerender"`
question from:https://stackoverflow.com/questions/65880417/angular-11-ssr-is-compiled-but-having-issue-with-prod-build-and-serve-no-content

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...