Autoprefixer for Ember CLI

2.0.0 · active · verified Wed Apr 22

ember-cli-autoprefixer is an Ember CLI addon designed to automatically add vendor prefixes to CSS rules in Ember applications, leveraging the popular PostCSS plugin Autoprefixer. It integrates directly into the Ember CLI build pipeline, processing stylesheets before they are served. The current stable version is 2.0.0. While it doesn't have a fixed release cadence, updates typically align with major releases of `broccoli-autoprefixer`, Autoprefixer itself, or significant changes in Ember CLI's build system (e.g., `config/targets.js`). Key differentiators include its seamless integration, automatic consumption of project-wide browser targets defined in `config/targets.js`, and explicit support for overriding browser targets or configuring Autoprefixer options directly within `ember-cli-build.js`. It also provides detailed guidance for managing CSS sourcemaps, especially when used in conjunction with `ember-cli-sass`, to prevent common build and debugging issues.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart installs the addon and demonstrates basic configuration in `ember-cli-build.js`, including setting browser targets and managing sourcemap generation based on the environment.

/* In your terminal */
ember install ember-cli-autoprefixer

/* In ember-cli-build.js */
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    // Configure autoprefixer options here
    autoprefixer: {
      // Explicitly define browser targets, overrides config/targets.js for this addon
      overrideBrowserslist: [
        'last 2 Chrome versions',
        'last 2 Firefox versions',
        'last 1 Safari versions',
        'last 2 Edge versions',
        'IE 11' // Example for specific browser
      ],
      cascade: false, // Disable cascade for cleaner output
      enabled: true // Ensure autoprefixer is enabled
    },
    // Example of disabling in production, common practice
    sassOptions: {
      sourceMap: process.env.EMBER_ENV !== 'production',
      sourceMapEmbed: process.env.EMBER_ENV !== 'production'
    }
  });

  return app.toTree();
};

view raw JSON →