-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Charles ⚡
committed
Aug 4, 2018
1 parent
b54f770
commit 2567996
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const postcss = require('postcss'); | ||
const fs = require('fs'); | ||
const Parker = require('parker/lib/Parker'); | ||
const metrics = require('parker/metrics/All'); | ||
const format = require('json-format'); | ||
|
||
let defaultOptions = { | ||
outputFile: './parker.json' | ||
}; | ||
|
||
module.exports = postcss.plugin('postcss-parker', options => { | ||
let opts = Object.assign({}, defaultOptions, options); | ||
|
||
return function(root, result) { | ||
let reporter = new Parker(metrics); | ||
|
||
const { css } = root.toResult(); | ||
|
||
let results = reporter.run(css); | ||
|
||
let output = format(results, { type: 'space', size: 2 }); | ||
|
||
fs.writeFile(opts.outputFile, output, err => { | ||
if (err) throw err; | ||
console.log('The file has been saved!'); | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "postcss-parker", | ||
"version": "0.1.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"json-format": "^1.0.1", | ||
"parker": "^0.0.10", | ||
"postcss": "^7.0.2" | ||
} | ||
} |