Package Exports
- ember-cli-less
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ember-cli-less) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ember-cli-less
Use Less to preprocess your ember-cli app's css.
Installation
npm install --save-dev ember-cli-lessUsage
By default, this addon will compile app/styles/app.less into dist/assets/app.css.
Additional options can be specified using the lessOptions config property in Brocfile.js:
var app = new EmberApp({
lessOptions: {...}
});Options:
paths: an array of include pathssourceMap: whether to generate source maps. Defaults totruein development.
Configuring Input/Output Paths
You can configure the input and output files using ember-cli's outputPaths option in Brocfile.js:
var app = new EmberApp({
outputPaths: {
app: {
css: {
'app': '/assets/my-project.css'
}
}
}
});You can also configure multiple input/output paths to generate multiple css files:
var app = new EmberApp({
outputPaths: {
app: {
css: {
'theme-orange': '/assets/theme-orange.css',
'theme-purple': '/assets/theme-purple.css'
}
}
}
});Usage in Addons
You can also use this to precompile less files in an addon. By default, this
will compile addon/styles/addon.less into css that will be merged into the
host app's css. (requires ember-cli >= 0.2.0):
- Install
ember-cli-lessin your addon'spackage.jsonunderdependencies - Create your addon less file at
addon/styles/addon.less(or where you specify in your options) - To run the addon's dummy app, be sure to create
tests/dummy/app/styles/app.lessif it doesn't exist
Examples
Using Bootstrap Less source in your app:
Install Bootstrap source:
bower install --S bootstrapSpecify the include paths in Brocfile.js:
var app = new EmberApp({
lessOptions: {
paths: [
'bower_components/bootstrap/less'
]
}
});Import into app.less:
@import 'bootstrap';Linking source maps
When setting sourceMap: true, a source map will be generated inline in the compiled css file.
When inspecting elements in dev tools (Chrome), you'll see the correct references to the original less files and their corresponding line numbers.
However, if you would like to click into the less source files directly, you have to link them to your local filesystem:
- Open dev tools > Sources tab
- Expand the sources pane on the left if it's not open
- Right-click anywhere, Add folder to workspace, add your project's folder
- Locate any less source file in the tree, right-click, Map to Network Resource... to create the mapping
References
- Code inspired by: ember-cli-sass. Credits to the author.
- broccoli-less-single