Skip to content

Instantly share code, notes, and snippets.

@johno
Created November 18, 2014 22:45
Show Gist options
  • Save johno/d688fcf1712bd3d4ccb2 to your computer and use it in GitHub Desktop.
Save johno/d688fcf1712bd3d4ccb2 to your computer and use it in GitHub Desktop.
Concatentate and minify assets with the Ember CLI
/* global require, module */
var css = require('broccoli-clean-css');
var concatFiles = require('broccoli-concat');
var removeFile = require('broccoli-file-remover');
var mergeTrees = require('broccoli-merge-trees');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp();
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
var appTree = app.toTree();
var compiledStyles = concatFiles(appTree, {
inputFiles: ['assets/' + app.name + '.css', 'assets/vendor.css'],
outputFile: '/assets/' + app.name + '.css'
});
var appTreeWithoutStyles = removeFile(appTree, {
files: ['assets/vendor.css']
});
compiledStyles = css(compiledStyles, {});
module.exports = mergeTrees([appTreeWithoutStyles, compiledStyles], { overwrite: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment