Skip to content

Commit

Permalink
Merge pull request #33 from zgreen/warning/quiet-from-to
Browse files Browse the repository at this point in the history
quiet PostCSS from/to warning
  • Loading branch information
zgreen authored Sep 23, 2018
2 parents 2fe9f2c + 6496435 commit 655a06e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const basePath = `${process.cwd()}/example`
function cb (files) {
function useFileData (data, file) {
postcss([postcssCriticalCSS({ outputPath: basePath })])
.process(data)
.process(data, { from: undefined, to: undefined })
.then(result => {
fs.writeFile(
`${basePath}/${file.split('.')[0]}.non-critical.css`,
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ function buildCritical() {
criticalOutput[cur].each(function (rule) {
return criticalCSS.append(rule.clone());
});
return (0, _postcss2.default)(minify ? [_cssnano2.default] : []).process(criticalCSS).then(dryRunOrWriteFile.bind(null, dryRun, filePath)).then(clean.bind(null, css, preserve));
return (0, _postcss2.default)(minify ? [_cssnano2.default] : [])
// @TODO Use from/to correctly.
.process(criticalCSS, {
from: undefined,
to: undefined
}).then(dryRunOrWriteFile.bind(null, dryRun, filePath)).then(clean.bind(null, css, preserve));
}, {});
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-critical-css",
"version": "3.0.1",
"version": "3.0.2",
"description": "Generate critical CSS using PostCSS",
"main": "index.js",
"repository": {
Expand Down
23 changes: 15 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ function dryRunOrWriteFile (
result: Object
): Promise<any> {
const { css } = result
return new Promise((resolve: Function): void =>
resolve(dryRun ? doDryRun(css) : writeCriticalFile(filePath, css))
return new Promise(
(resolve: Function): void =>
resolve(dryRun ? doDryRun(css) : writeCriticalFile(filePath, css))
)
}

Expand Down Expand Up @@ -164,13 +165,19 @@ function buildCritical (options: Object = {}): Function {
(init: Object, cur: string): Function => {
const criticalCSS = postcss.root()
const filePath = path.join(outputPath, cur)
criticalOutput[cur].each((rule: Object): Function =>
criticalCSS.append(rule.clone())
criticalOutput[cur].each(
(rule: Object): Function => criticalCSS.append(rule.clone())
)
return (
postcss(minify ? [cssnano] : [])
// @TODO Use from/to correctly.
.process(criticalCSS, {
from: undefined,
to: undefined
})
.then(dryRunOrWriteFile.bind(null, dryRun, filePath))
.then(clean.bind(null, css, preserve))
)
return postcss(minify ? [cssnano] : [])
.process(criticalCSS)
.then(dryRunOrWriteFile.bind(null, dryRun, filePath))
.then(clean.bind(null, css, preserve))
},
{}
)
Expand Down

0 comments on commit 655a06e

Please sign in to comment.