angular-cli: Angular compiler option preserveWhitespaces: true does not work in >6.0.0 final
Versions
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.1
Node: 8.11.1
OS: win32 x64
Angular: 6.0.1
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/build-angular 0.6.1
@angular-devkit/build-optimizer 0.6.1
@angular-devkit/core 0.6.1
@angular-devkit/schematics 0.6.1
@ngtools/webpack 6.0.1
@schematics/angular 0.6.1
@schematics/update 0.6.1
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
Repro steps
- Added
"angularCompilerOptions": { "preserveWhitespaces": true }
into tsconfig.json like https://angular.io/guide/aot-compiler#angular-compiler-options says - Run ng serve, ng serve --aot, ng build, ng build --aot, ng build --prod --aot
Observed behavior
"preserveWhitespaces": true
doesn’t affect ng serve nor ng build
Desired behavior
ng serve and ng build should preserve whitespaces globally
Mention any other details that might be useful (optional)
I’ve modified my main.ts file for working on ng serve:
platformBrowserDynamic().bootstrapModule(AppModule, {
preserveWhitespaces: true
})
.catch(err => console.log(err));
but production build still is not preserving white spaces globally
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 15 (2 by maintainers)
@criduvero your original code snippet is the correct way to set preserveWhitespaces for JIT.
So to summarize: In order to set angular compiler options in AOT compile (
ng serve --aot
,ng build --prod
) you must alter the tsconfig.app.json to include:In order to set angular compiler options in JIT compile (
ng serve
) you must alter main.ts specifically the bootstrapModule call:To be consistent between JIT and AOT, you must alter both files!
I still have the problem !! I’ve put preserveWhitespaces: true in tsconfig.app.json, in tsconfig.json and in options of bootstrapModule but it don’t works. The only way I’ve found is to put preserveWhitespaces: true in all the components !!
Anyone has still the problem ?
Angular V.6.1.7