Ember CLI Clean CSS Addon

3.0.0 · active · verified Tue Apr 21

ember-cli-clean-css is an Ember CLI addon designed to integrate the `clean-css` library into an Ember.js application's build pipeline. It automatically minifies CSS files during development and production builds, aiming to optimize their size for improved loading performance. The current stable version, 3.0.0, primarily features an upgrade to `clean-css` version 5, bringing the latest minification capabilities and features. Its release cadence is generally aligned with updates to `ember-cli` and `clean-css`. This addon differentiates itself by offering a straightforward, low-configuration approach to CSS minification within the Ember ecosystem, directly hooking into the asset build process without requiring manual `clean-css` invocation or complex configuration, making it an essential tool for optimizing Ember application stylesheets.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install the addon and provide basic configuration for `clean-css` options within your `ember-cli-build.js` file, including conditional source map generation.

ember install ember-cli-clean-css

// Then, in your ember-cli-build.js file, configure options:
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    'ember-cli-clean-css': {
      enabled: true, // Set to false to disable minification
      level: {
        1: { 
          all: true, // Set all level 1 optimizations to true
          specialComments: 'none' // Remove all special comments (e.g., @licence)
        },
        2: {
          all: true // Set all level 2 optimizations to true
        }
      },
      // Other clean-css options can be added here
      sourceMap: app.isProduction() // Generate source maps only in production
    }
  });

  return app.toTree();
};

view raw JSON →