Skip to content

.scss not working #1189

Closed
Closed

Description

@Kim-Andersen

OSX El Capitan
angular-cli: 1.0.0-beta.6
node: 5.9.0
os: darwin x64
App created using angular-cli.

I can't get .scss files working. I installed node-sass and renamed .css files to .scss, and get a 404 on the missing .css file.

What am I missing?

Activity

  1. choucry13 commented on Jun 24, 2016

    @choucry13

    if you want to use .scss to css in your code, lauch the commande :
    node-sass -w directoryOfFile.scss -o directoryOfFile.css
    -w is a watcher when you edit you file scss.
    In your component, you write just the css file.
    That's clear for you or do you want a example ?

  2. Kim-Andersen commented on Jun 24, 2016

    @Kim-Andersen
    Author

    I was under the impression, hence the angular-cli documentation, that all you have to do is install node-sass and rename to .scss. That is not the case then, I suppose.

    However, your pseudo code makes sense, thanks.

  3. Kim-Andersen commented on Jun 24, 2016

    @Kim-Andersen
    Author

    The documentation says: "To use one just install for example npm install node-sass and rename .css files in your project to .scss or .sass. They will be compiled automatically."

    This is why I thought it should work out of the box.

  4. ghidoz commented on Jun 24, 2016

    @ghidoz

    Did you only renamed .css files to .scss or you also renamed file names in your components?
    Because you should have app.component.scss, but the component itself should reference app.component.css

  5. briananderson1222 commented on Jun 24, 2016

    @briananderson1222

    ^_^ using what @ghidoz said has been working fine for me for over 2 months now :)

  6. KrisTemmerman commented on Jun 27, 2016

    @KrisTemmerman

    it doesn't work for me either, changed the filename to xxx.component.scss. output:
    `GET http://localhost:4200/app/xxx.component.css 404 (Not Found)``

  7. ghidoz commented on Jun 27, 2016

    @ghidoz

    If you want, I set up a starter project based on Angular CLI, with some more feature: https://github.com/ghidoz/angular2-starter
    You can clone it or you can just have a look at how I set up the CSS configuration, allowing also includes. Refer to this commit for details: https://github.com/ghidoz/angular2-starter/commit/1e6a8cdea6c7b3d8d3d119482efc210d6e19620a

  8. renevall commented on Jun 29, 2016

    @renevall

    nvm just changing name to scss did the trick in the end.

  9. renevall commented on Jun 29, 2016

    @renevall

    Ok something is weird, when I update the css file, it does compile and output file to dist folder. But ngserve seems to be getting an empty css file, which I interprets as it is not using the dist folder.

  10. MrHus commented on Jul 1, 2016

    @MrHus

    It is not working for me as well, my environment is:

    angular-cli: 0.0.39
    node: 5.3.0
    os: darwin x64
    

    I installed "node-sass": "^3.8.0".

    I've got the following cheese component:

    import { Component } from '@angular/core';
    
    @Component({
      moduleId: module.id,
      selector: 'cheese-app',
      templateUrl: 'cheese.component.html',
      styleUrls: ['cheese.component.css'] // According to @ghidoz this is correct right?
    })
    export class CheeseAppComponent {
      title = 'cheese works!';
    }

    And the following scss file called cheese.component.scss:

    h1 {
      color:red;
    }
  11. zackarychapple commented on Jul 1, 2016

    @zackarychapple
    Contributor

    @MrHus you are on a very old version of the CLI that is pre ng-conf. Upgrade your environment and retest please.

  12. MrHus commented on Jul 1, 2016

    @MrHus

    I've upgraded to 1.0.0-beta.8 and it works now.

  13. vadym-k21 commented on Nov 14, 2016

    @vadym-k21

    @filipesilva Hi! I still have this problem on beta19.
    Structure:

    app/src/editor/editor.component.ts
    app/src/editor/editor.component.scss
    app/src/editor/editor.component.spec.ts
    

    In Component:

    @Component({
        selector: 'editor',
        styleUrls: ['editor.component.css'],
        template: `
            <div class="content-area--wrapper">
                <div class="content-area--body" [dragula]='"moveBlocks"'>
                        <core-widget-component class="block--wrapper" [attr.data-id]="el.blockId"
                            *ngFor="let el of page.page_content.elements" 
                            [widget]="el"
                            [parent]="'topLevelComponent'">
                        </core-widget-component>
                </div>
            </div>
    `
    })
    

    What is the problem here?

  14. filipesilva commented on Nov 21, 2016

    @filipesilva
    Contributor

    @vadym-kukhtin use a relative path ./editor.component.css.

  15. vadym-k21 commented on Nov 22, 2016

    @vadym-k21

    @filipesilva The same for ./editor.component.scss.
    If I am migrating ng2 components that were written not using ng-cli - it doesn't work, fot those - created by ng-cli - everything works

  16. anrtero commented on Feb 28, 2017

    @anrtero

    try setting default style extension with command ng set defaults.styleExt scss

  17. demiro commented on May 8, 2017

    @demiro

    For me, when I use cli to generate components the syntax is all good... references it via the scss (styleUrls)...
    but ng serve picks up only app.component.scss and not any other components...

  18. kloncentaur8 commented on Jun 1, 2017

    @kloncentaur8

    here is a fix, put this in your .angular-cli.json:

    "stylePreprocessorOptions": { "includePaths": [ "../node_modules" ] },

  19. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  20. locked and limited conversation to collaborators on Sep 7, 2019
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions