Skip to content

SASS/LESS pre-compilation and altering generated file prefixes #120

Closed

Description

@intellix

So I was looking at adding SASS compilation to the build process of this. Typically in the past I've been telling it to compile particular files (app.scss and vendor.scss) but with ng2 and it's Shadow DOM style encapsulation I guess it's going to make sense to have a .SCSS per component.

I suppose my issue is that alongside this, we need a way to alter the pre-generated .css to have a .scss prefix instead.

SASS compilation was achieved (for anyone else interested):

/* global require, module */

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
var compileSass = require('broccoli-sass');
var mergeTrees = require('broccoli-merge-trees');
var _ = require('lodash');
var glob = require('glob');

module.exports = function(defaults) {
    var app = new Angular2App(defaults);
    var app = app.toTree();

    var styles = mergeTrees(_.map(glob.sync('src/**/*.scss'), function(sassFile) {
        sassFile = sassFile.replace('src/', '');
        return compileSass(['src'], sassFile, sassFile.replace(/.scss$/, '.css'));
    }));

    return mergeTrees([styles, app], { overwrite: true });
}

Activity

  1. wesleycho commented on Dec 18, 2015

    @wesleycho
    Contributor

    My work in #115 should pave the way for adding LESS/SASS/SCSS support, assuming after review/modifications it is accepted.

  2. friksa commented on Jan 4, 2016

    @friksa

    +1 for Sass

  3. wearska commented on Jan 5, 2016

    @wearska

    +1
    Actually waiting for this to start using it. Can't just write plain css... :|

  4. wearska commented on Jan 20, 2016

    @wearska

    The above code doesnt work for me..

    If 'ng-server' is running, when a new component is generated, (I've added a "name_.scss" file to the blueprints), when I change the .scss file, the .css file does not get compiled. As soon as I restart the server, it compiles successfully and also after every change. But when a new component is generated, it won't compile. Basically, the server is not watching for changes in the newly added .scss file, even though it logs its creation when the component is generated.

  5. intellix commented on Feb 24, 2016

    @intellix
    ContributorAuthor

    I believe the newly added file problem plagues most generators :)

  6. hansl commented on Mar 17, 2016

    @hansl
    Contributor

    Closing this as we are definitely taking LESS and SASS into account for third party libraries. See #255.

  7. angular-automatic-lock-bot commented on Sep 5, 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.

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