angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

AoT issue with stylePreprocessorOptions in multiapp setup

Open sasxa opened this issue 9 years ago • 3 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

In multiapp setup where apps use different style preprocessor building in AoT mode throws an error. Compiler is processing files that are not part of the app that's being built.

Versions.

Angular CLI: 1.5.0
Node: 8.5.0
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.3
typescript: 2.6.1
webpack: 3.8.1

Repro steps.

  1. Clone: https://github.com/sasxa/cli-8502
  2. npm install
  3. Working: ng build --app one --aot false
  4. Not working: ng build --app one --aot true

The log given by the failure.

Error: C:\~\apps\two\src\app\app.component.styl:1:9
   1| @import variables
--------------^
   2|
   3| body
   4|     background: $color

failed to locate @import file variables.styl

Notice that error comes from app two source, even though cli is building app one. Same happens with:

ng build --app two --aot true
ERROR in Error: Child compilation failed:
Module build failed:
@import 'variables';
^
      File to import not found or unreadable: variables.
Parent style sheet: stdin
      in C:\~\apps\one\src\app\app.component.scss (line 1, column 1):

Desired functionality.

Should build without errors...

Mention any other details that might be useful.

In my apps I'm importing only variables.styl and _variables.scss, so copying these files in appropriate folders makes build pass. In sample repo it would be:

C:\~\apps\one\src\styles\variables.styl - app one is using sass preprocessor
C:\~\apps\two\src\styles\variables.scss - app two is using stylus preprocessor

sasxa avatar Nov 15 '17 19:11 sasxa

Do you reuse your tsconfig.app.json? The tsconfig that's provided by default includes ALL the files in the src/ directory. You need to specify either exclude, includes, or files property in the tsconfig to limit which files each app should build.

Closing this as answered.

hansl avatar Nov 20 '17 19:11 hansl

@hansl Thanks! Adding tsconfig.json for each app and updating .angular-cli.json solves the issue:

C:\~\apps\one\src\tsconfig.json
C:\~\apps\two\src\tsconfig.json
{
  "extends": "../../../tsconfig.app.json",
  "include": [
    "."    
  ]
}

sasxa avatar Nov 21 '17 02:11 sasxa

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.