Skip to content

feat: add sass support #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addon/ng2/blueprints/ng2/files/src/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// --------------------------------
// Import all your other sass files below
// Note: Order counts, so import your variables and mixins first
// --------------------------------

// e.g. @import 'app/components/example/example.scss'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listing every single scss file here is too error prone and besides, angular compiler will fetch all css files and prefix all selectors by default to provide css isolation. so we definitely don't want to list individual files here.

2 changes: 1 addition & 1 deletion addon/ng2/blueprints/ng2/files/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="vendor/systemjs/dist/system.src.js"></script>
<script src="vendor/angular2/bundles/angular2.dev.js"></script>
{{content-for 'head'}}
<script>
<link rel="stylesheet" href="app.css">
System.config({
packages: {
app: {
Expand Down
11 changes: 9 additions & 2 deletions lib/broccoli/angular2-app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Concat = require('broccoli-concat');
var configReplace = require('./broccoli-config-replace');
var compileWithTypescript = require('./broccoli-typescript').default;
var compileSass = require('broccoli-sass');
var fs = require('fs');
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
Expand All @@ -23,6 +24,12 @@ Angular2App.prototype.toTree = function () {
allowEmpty: true
});

var sassTree = compileSass([sourceTree], 'app/app.scss', 'app/app.css');
var sassSrcTree = new Funnel(sourceTree, {
include: ['**/*.sass'],
allowEmpty: true
});

var jsTree = new Funnel(sourceTree, {
include: ['**/*.js'],
allowEmpty: true
Expand Down Expand Up @@ -52,7 +59,7 @@ Angular2App.prototype.toTree = function () {
// outputFile: '/app.js'
// });

return mergeTrees([assetTree, tsSrcTree, tsTree, jsTree, this.index(), vendorJsTree], { overwrite: true });
return mergeTrees([assetTree, tsSrcTree, tsTree, sassSrcTree, sassTree, jsTree, this.index(), vendorJsTree], { overwrite: true });
};

/**
Expand Down Expand Up @@ -183,4 +190,4 @@ Angular2App.prototype.index = function() {
files: [ htmlName ],
patterns: this._configReplacePatterns()
});
};
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
]
},
"devDependencies": {
"broccoli-sass": "^0.7.0",
"broccoli-stew": "^0.3.6",
"chai": "^3.2.0",
"exists-sync": "0.0.3",
Expand Down