├── .gitignore ├── .travis.yml ├── History.md ├── Readme.md ├── lib └── index.js ├── package.json └── test ├── fixtures ├── basic │ ├── expected │ │ └── style.css │ └── src │ │ └── style.css └── options │ ├── expected │ └── style.css │ └── src │ └── style.css └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | *.DS_Store 10 | *.swp 11 | 12 | pids 13 | logs 14 | results 15 | 16 | node_modules 17 | components 18 | test/fixtures/**/build 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | - "0.11" 5 | - "0.10" 6 | install: 7 | - npm update 8 | - npm install 9 | script: npm test 10 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 1.0.0 / 2015-03-03 3 | ================== 4 | 5 | * add autoprefixer options 6 | 7 | 0.1.2 / 2014-04-01 8 | ================== 9 | 10 | * remove 0.8 support from travis 11 | * remove node 0.6 support from travis 12 | * travis config updates 13 | * adds travis badge 14 | * rename travis config 15 | * updates travis config 16 | * adds travis config 17 | * adds basic test 18 | * adds semicolons 19 | 20 | 0.1.0 / 2014-04-01 21 | ================== 22 | * Initial commit 23 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | metalsmith-autoprefixer 2 | =============== 3 | 4 | [![Build Status](https://travis-ci.org/esundahl/metalsmith-autoprefixer.svg?branch=master)](https://travis-ci.org/esundahl/metalsmith-autoprefixer) 5 | ![Dependencies](https://david-dm.org/esundahl/metalsmith-autoprefixer.png) 6 | 7 | An [Autoprefixer](https://github.com/ai/autoprefixer) plugin for Metalsmith. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install --save metalsmith-autoprefixer 13 | ``` 14 | 15 | ## Getting Started 16 | 17 | If you haven't checked out [Metalsmith](http://metalsmith.io/) before, head over to their website and check out the 18 | documentation. 19 | 20 | In order to use this plugin, you need to include the `autoprefixer` module in your `package.json` file: 21 | ```json 22 | { 23 | ... 24 | "dependencies": { 25 | ... 26 | "autoprefixer": "*" 27 | } 28 | 29 | } 30 | ``` 31 | 32 | ## CLI Usage 33 | 34 | If you are using the command-line version of Metalsmith, you can install via npm, and then add the 35 | `metalsmith-autoprefixer` key to your `metalsmith.json` file: 36 | 37 | ```json 38 | { 39 | "plugins": { 40 | "metalsmith-autoprefixer": {} 41 | } 42 | } 43 | ``` 44 | 45 | ## JavaScript API 46 | 47 | If you are using the JS Api for Metalsmith, then you can require the module and add it to your 48 | `.use()` directives: 49 | 50 | ```js 51 | var autoprefixer = require('metalsmith-autoprefixer'); 52 | 53 | metalsmith.use(autoprefixer()); 54 | ``` 55 | 56 | ## Options 57 | 58 | None yet 59 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 2 | var minimatch = require('minimatch'); 3 | var postcss = require('postcss'); 4 | 5 | 6 | function plugin (opts) { 7 | var opts = opts || {}; 8 | var autoprefixer = require('autoprefixer-core')(opts); 9 | return function (files, metalsmith, done) { 10 | var styles = Object.keys(files).filter(minimatch.filter("*.css", { matchBase: true })); 11 | setImmediate(done); 12 | styles.forEach(function (file, index, arr) { 13 | files[file].contents = new Buffer(postcss([autoprefixer]).process(files[file].contents.toString()).css); 14 | }); 15 | } 16 | } 17 | 18 | module.exports = plugin; 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "metalsmith-autoprefixer", 3 | "version": "1.1.0", 4 | "description": "metalsmith autoprefixer plugin", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "test": "./node_modules/mocha/bin/mocha" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/esundahl/metalsmith-autoprefixer" 12 | }, 13 | "keywords": [ 14 | "metalsmith", 15 | "autoprefixer" 16 | ], 17 | "author": "Erik Sundahl", 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/esundahl/metalsmith-autoprefixer/issues" 21 | }, 22 | "homepage": "https://github.com/esundahl/metalsmith-autoprefixer", 23 | "peerDependency": { 24 | "autoprefixer": "*" 25 | }, 26 | "dependencies": { 27 | "autoprefixer-core": "^5.2.1", 28 | "minimatch": "^3.0.3", 29 | "postcss": "^4.1.11" 30 | }, 31 | "devDependencies": { 32 | "assert-dir-equal": "^1.0.1", 33 | "metalsmith": "^1.3.0", 34 | "mocha": "^2.1.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/fixtures/basic/expected/style.css: -------------------------------------------------------------------------------- 1 | @-webkit-keyframes fade-in-down-big { 2 | 0% { 3 | opacity: 0; 4 | -webkit-transform: translateY(-2000px); 5 | transform: translateY(-2000px); 6 | } 7 | 8 | 100% { 9 | opacity: 1; 10 | -webkit-transform: translateY(0); 11 | transform: translateY(0); 12 | } 13 | } 14 | 15 | @keyframes fade-in-down-big { 16 | 0% { 17 | opacity: 0; 18 | -webkit-transform: translateY(-2000px); 19 | transform: translateY(-2000px); 20 | } 21 | 22 | 100% { 23 | opacity: 1; 24 | -webkit-transform: translateY(0); 25 | transform: translateY(0); 26 | } 27 | } 28 | 29 | .fade-in-down-big { 30 | -webkit-animation-name: fade-in-down-big; 31 | animation-name: fade-in-down-big; 32 | } 33 | -------------------------------------------------------------------------------- /test/fixtures/basic/src/style.css: -------------------------------------------------------------------------------- 1 | @keyframes fade-in-down-big { 2 | 0% { 3 | opacity: 0; 4 | transform: translateY(-2000px); 5 | } 6 | 7 | 100% { 8 | opacity: 1; 9 | transform: translateY(0); 10 | } 11 | } 12 | 13 | .fade-in-down-big { 14 | animation-name: fade-in-down-big; 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/options/expected/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | -webkit-animation-name: 'foo'; 3 | animation-name: 'foo'; 4 | } -------------------------------------------------------------------------------- /test/fixtures/options/src/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | animation-name: 'foo'; 3 | } -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 2 | var assertDir = require('assert-dir-equal') 3 | var autoprefixer = require('../') 4 | var Metalsmith = require('metalsmith') 5 | 6 | describe('metalsmith-autoprefixer', function() { 7 | it('should add some prefixes', function(done){ 8 | Metalsmith('test/fixtures/basic') 9 | .use(autoprefixer({ browsers: 'Chrome 30' })) 10 | .build(function(err) { 11 | if (err) return done(err) 12 | assertDir('test/fixtures/basic/expected', 'test/fixtures/basic/build') 13 | return done(null) 14 | }) 15 | }) 16 | it('should take options and propagate to autoprefixer', function(done){ 17 | Metalsmith('test/fixtures/options') 18 | .use(autoprefixer({ browsers: 'Chrome 30', cascade: false })) 19 | .build(function(err) { 20 | if (err) return done(err) 21 | assertDir('test/fixtures/options/expected', 'test/fixtures/options/build') 22 | return done(null) 23 | }) 24 | }) 25 | }) 26 | --------------------------------------------------------------------------------