ng build --prod包比ng serve --prod

时间:2019-03-06 03:58:49

标签: angular build angular6

参考link

在部署的应用程序初始加载页面太慢之后,则使用--prod --vendor-chunk = true开发模式。

当我运行命令时:ng serve --prod --vendor-chunk = true

应用程序加载时间不到3秒

  

块{0} runtime.ff327676ae0e587a3b7d.js(运行时)2.23 kB [entry]

     

main.147e094c9169dae8bf28.js(主要)2.27 MB //以毫秒为单位

     

(polyfills)59.6 kB [初始] [渲染]块{3} //这里以毫秒为单位

     

styles.b6e688de30655ff1967d.css(样式)486 kB [初始] [呈现] //此处以毫秒为单位

     

chunk {4} 4.a1fc274936dc714d8009.js()1.45 MB [rendered] //此处以毫秒为单位

运行命令:ng build --prod --vendor-chunk = true

部署应用程序后,为什么捆绑包大小以秒而不是毫秒为单位运行。我传递了与ng seve相同的命令。

应用程序加载时间不到10秒。

  

styles.b6e688de30655ff1967d.css 200样式表(索引)83.9 KB 945秒

     

ms runtime.ff327676ae0e587a3b7d.js 200脚本(索引)1.3 KB 1.21秒//需要减小主包js的大小(以毫秒为单位)

     

s polyfills.677bdac3385565b157aa.js 200脚本(索引)22.6 KB 1.42秒//(以毫秒为单位)

     

s vendor.fb8b03b6b86ccf2be1e2.js 200脚本(索引)349 KB 4.84秒//(以毫秒为单位)

     

s main.8cb1a0939213dd22e7fb.js 200脚本(索引)213 KB 4.53秒//(以毫秒为单位)

tsconfig.json

"compilerOptions": {
    "rootDir": ".",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }

0 个答案:

没有答案
相关问题