Style is missing when build with --bundle


#1

I have a NativeScript-Angular demo app with below version and project file structure.

Version

  • nativescript: 3.4.1
  • nativescript-cli: 3.4.1
  • nativescript-angular: 5.2.0
  • webpack, 3.10.0
  • @ngtools/webpack: 1.9.5
  • nativescript-dev-webpack: 0.9.1

Used cli created a brand new project and ran belown command.

tns run android --bundle --env.uglify --env.aot

The response is

Module build failed: Error: D:\Dev\Workspace\nativescript-app\app\main.aot.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the ‘files’ or ‘include’ property.

I am not sure why a new created project cannot be build with aot flag. I checked the tsconfig.json and found this.

"exclude": [
    "node_modules",
    "platforms",
    "**/*.aot.ts"
]

I tried to remove the line “**/*.aot.ts” and re ran the command. This time it worked. But when app poped up on the screen, all styles lost. Looks like the css files were not included.

I just felt I cannot just remove “**/*.aot.ts” from tsconfig.json. But I did not find any useful info from official docs.

Even I just ran

tns run android --bundle

The same result, style missed.

Any help would be appreciated.


#2

Sorry, my fault. This project is a upgraded from previous version. When I used cli to create a new project and ran this command, everything worked as I expected.