angular有一个新的选项,preserveWhitespaces,从模板代码中删除非重要的空白字符,让应用程序的最终大小进一步压缩。这个选项默认是关闭的。需要把它添加到全局的tsconfig.json文件。
{
"compileOnSave": false ,
"compilerOptions" : {
"outDir": "./dist/out-tsc" ,
"sourceMap": true ,
"declaration": false ,
"moduleResolution": "node" ,
"emitDecoratorMetadata": true ,
"experimentalDecorators": true ,
"target": "es5" ,
"typeRoots": ["node_modules/@types" ],
"lib": ["es2017", "dom" ]
},
"angularCompilerOptions" : {
"preserveWhitespaces": false
}
}
这个选项也可以在某个组件上使用,在组件的@component中添加preseveWhitespaces:false。
待续...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did223016