Skip to content

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

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

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