Skip to content

scss not compiled with the latest aot configuration #1310

Closed

Description

@tothonx

Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @AngularClass

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository

  • What is the current behavior?

I am currently adjusting my code for the AOT compilation but I have an issue with my scss. (im also using sass loader with webpack)
Here is the compilation error :

Error: Compilation failed. Resource file not found: /home/bsousa/Projects/email-builder/src/app/sass/mixins.scss
    at ModuleResolutionHostAdapter.readResource (/home/bsousa/Projects/email-builder/node_modules/@angular/compiler-cli/src/compiler_host.js:270:19)
    at CompilerHost.loadResource (/home/bsousa/Projects/email-builder/node_modules/@angular/compiler-cli/src/compiler_host.js:230:85)


see #1304

  • What is the expected behavior?

It should compiled everything with node sass.

  • Please tell us about your environment:
  • Angular version: 2.4.1

Activity

  1. shlomiassaf commented on Dec 29, 2016

    @shlomiassaf
    Contributor

    @BkSouX , This is a SCSS file referenced in a component's styleUrls, right?

    Please give more info...

  2. shlomiassaf commented on Dec 29, 2016

    @shlomiassaf
    Contributor

    I can only guess since there's not a lot of information...

    But it looks like you're trying to load a global scss file from within a component styleUrls... right?

  3. feddyups commented on Dec 30, 2016

    @feddyups

    @shlomiassaf : You are correct, this happens also in my case, the scss files are being loaded directly through the component's styleUrls.

    An Idea would be to configure the test: /\.scss$/ rule to work with "extract-text-webpack-plugin": "^2.0.0-beta.4", so we can extract css files into the components' dirs and change our templateUrl reference to point to this?

  4. shlomiassaf commented on Dec 31, 2016

    @shlomiassaf
    Contributor

    @feddyups No, test: /\.scss$/ is to generic, it will take all SCSS files and send them to the header.

    There are 2 types of stylesheets in an angular 2 application

    • Global styles (goes to head)
    • Component styles (live within the component)

    Each component has a ViewEncapsulation property that defines the interaction of the styles so it's important to have SCSS files stay within the component.

    Global styles can be in a specific app or prefixed, it's up to you actually (see #1304 and comments)

    @BkSouX The error you posted indicates that the @angular/compiler tried to fetch a resource that was in the styleUrls of a component but it wasn't there.

    This error also indicates that you are using an older version of this repo since this resource is loaded by the compiler-cli and not ngc-webpack

    Anyway, if the file is not present ngc-webpack will throw as well...

    check your files...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions