ember-stylus uses broccoli-stylus-single to preprocess your ember-cli app's files and provides support for source maps and include paths. It provides support for the common use case for Ember.js projects:
- Source maps by default in development
- Support for
outputPaths
configuration - Provides the ability to specify include paths
ember install ember-stylus
If you want to use ember-stylus in an addon and you want to distribute the compiled CSS it must be installed as a dependency
so that addon/styles/addon.styl
is compiled into dist/assets/vendor.css
. This can be done using:
npm install --save ember-stylus
By default this addon will compile app/styles/app.styl
into dist/assets/[app-name].css
and produce
a source map for your delectation.
If you want more control then you can specify options using the
stylusOptions
config property in ember-cli-build.js
(or in Brocfile.js
if you are using an Ember CLI version older than 1.13):
var app = new EmberApp({
stylusOptions: {...}
});
includePaths
: an array of include pathssourceMap
: controls whether to generate sourceMaps, defaults totrue
in development. The sourceMap file will be saved tooptions.outputFile + '.map'
If you need to process multiple files, it can be done by configuring the output paths in your ember-cli-build.js
:
var app = new EmberApp({
outputPaths: {
app: {
css: {
'app': '/assets/application-name.css',
'themes/alpha': '/assets/themes/alpha.css'
}
}
}
});
The following example assumes your bower packages are installed into node_modules/
.
Install some Stylus:
npm install --save-dev kouto-swiss
Specify some include paths in your ember-cli-build.js
:
var app = new EmberApp({
stylusOptions: {
includePaths: [
'node_modules/kouto-swiss'
]
}
});
Import some deps into your app.scss:
@import 'kouto-swiss'; /* import everything */
/* or just import the bits you need: @import 'kouto-swiss/functions'; */
To compile Stylus within an ember-cli addon, there are a few additional steps:
-
Include your styles in
addon/styles/addon.styl
. -
Ensure you've installed
ember-stylus
underdependencies
in yourpackage.json
. -
Define an
included
function in your app:// in your index.js module.exports = { name: 'my-addon', included: function(app) { this._super.included(app); } };
-
Make sure your dummy app contains an
app.scss
-
If you run
ember build dist
, your styles fromaddon/styles/addon.styl
should appear correctly indist/assets/vendor.css
For an example of an addon that does this correctly, see ember-cli-notifications