Skip to content

Commit

Permalink
Added autoprefixer transform to buildProduction transform and binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Munter committed Jan 19, 2014
1 parent 4b3a9d7 commit beaff44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bin/buildProduction
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ var optimist = require('optimist'),
type: 'boolean',
default: false
})
.options('autoprefix', {
describe: 'Automatically prefix all css based on the rules supplied. See https://github.com/ai/autoprefixer#browsers',
type: 'string',
demand: false
})
.options('debug', {
describe: 'Keep statement level console.*() calls and debugger statements in JavaScript assets',
type: 'boolean',
Expand Down Expand Up @@ -229,6 +234,10 @@ if (commandLineOptions.inlinesize) {
inlineByRelationType.CssImage = 8192;
}

if (commandLineOptions.autoprefix && typeof commandLineOptions === 'string') {
commandLineOptions.autoprefix = [commandLineOptions.autoprefix];
}

(commandLineOptions.define ? _.flatten(_.flatten([commandLineOptions.define])) : []).forEach(function (define) {
var matchDefine = define.match(/^(\w+)(?:=(.*))?$/);
if (matchDefine) {
Expand Down Expand Up @@ -314,6 +323,7 @@ new AssetGraph({root: rootUrl})
less: !commandLineOptions.noless,
optimizeImages: commandLineOptions.optimizeimages,
inlineByRelationType: inlineByRelationType,
autoprefix: commandLineOptions.autoprefix,
gzip: commandLineOptions.gzip,
defines: defines,
reservedNames: reservedNames,
Expand Down
4 changes: 1 addition & 3 deletions lib/transforms/autoprefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
var autoprefix = require('autoprefixer');

module.exports = function (options) {
options = options || {};

// See https://github.com/ai/autoprefixer#browsers
var browsers = options.browsers;
var browsers = options;

return function autoprefixer(assetGraph) {
assetGraph.findAssets({type: 'Css'}).forEach(function (cssAsset) {
Expand Down
3 changes: 3 additions & 0 deletions lib/transforms/buildProduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ module.exports = function (options) {
return assetGraph;
})
.removeNobundleAttribute({type: ['HtmlScript', 'HtmlStyle']})
.if(options.autoprefix)
.autoprefixer(options.autoprefix)
.endif()
.if(inlineByRelationType.CssImage)
.inlineCssImagesWithLegacyFallback({type: 'Html', isInline: false, isFragment: false}, inlineByRelationType.CssImage)
.endif()
Expand Down

0 comments on commit beaff44

Please sign in to comment.