Skip to content

Commit 39674dd

Browse files
committed
autoprefixer
1 parent 1aa2e2c commit 39674dd

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

bin/build.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ var stream2promise = require('stream-to-promise');
99
var uglify = require('uglify-js');
1010
var CleanCss = require('clean-css');
1111
var cleanCss = new CleanCss();
12+
var autoprefixer = require('autoprefixer');
13+
var postcss = require('postcss');
1214
var execall = require('execall');
1315
var minifyHtml = require('html-minifier').minify;
1416
var bundleCollapser = require("bundle-collapser/plugin");
@@ -27,6 +29,12 @@ var CRITICAL_CSS_SPRITES_LINES = 8;
2729

2830
module.exports = async function build(debug) {
2931

32+
async function minifyCss(css) {
33+
var processed = await postcss([ autoprefixer ]).process(css);
34+
css = processed.css;
35+
return cleanCss.minify(css).styles;
36+
}
37+
3038
async function inlineSvgs(criticalCss) {
3139
var svgRegex = /url\((.*?\.svg)\)/g;
3240
var svgs = execall(svgRegex, criticalCss);
@@ -62,9 +70,9 @@ module.exports = async function build(debug) {
6270
spritesCss.split('\n').slice(0, CRITICAL_CSS_SPRITES_LINES).join('\n');
6371

6472
mainCss = await inlineSvgs(mainCss);
65-
mainCss = cleanCss.minify(mainCss).styles;
73+
mainCss = await cleanCss.minify(mainCss).styles;
6674
var muiCss = await fs.readFileAsync('./src/vendor/mui.css', 'utf-8');
67-
muiCss = cleanCss.minify(muiCss).styles;
75+
muiCss = await minifyCss(muiCss);
6876
return html
6977
.replace(
7078
'<link href="vendor/mui.css" rel="stylesheet"/>',
@@ -104,14 +112,6 @@ module.exports = async function build(debug) {
104112
await fs.writeFileAsync('./www/index.html', html, 'utf-8');
105113
}
106114

107-
async function getCss(filename) {
108-
var css = await fs.readFileAsync(filename, 'utf-8');
109-
if (debug) {
110-
return cleanCss.minify(css).styles;
111-
}
112-
return css;
113-
}
114-
115115
async function writeSplitCss(css, filename, numParts) {
116116
css = css.split('\n');
117117
var batchSize = (css.length / numParts);
@@ -122,7 +122,7 @@ module.exports = async function build(debug) {
122122
var cssPart = css.slice(i, i + end).join('\n');
123123
var partFile = filename.replace(/\.css$/, `-${counter}.css`);
124124
if (!debug) {
125-
cssPart = cleanCss.minify(cssPart).styles;
125+
cssPart = await minifyCss(cssPart);
126126
}
127127
promises.push(fs.writeFileAsync(partFile, cssPart, 'utf-8'));
128128
counter++;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"author": "Nolan Lawson <nolan@nolanlawson.com>",
1616
"license": "Apache-2.0",
1717
"devDependencies": {
18+
"autoprefixer": "^6.1.0",
1819
"babel": "^5.8.29",
1920
"babel-eslint": "^4.1.3",
2021
"babelify": "^6.4.0",
@@ -42,6 +43,7 @@
4243
"ncp": "^2.0.0",
4344
"node-fetch": "^1.3.3",
4445
"node-watch": "^0.3.4",
46+
"postcss": "^5.0.11",
4547
"pouchdb": "^5.0.0",
4648
"pouchdb-find": "^0.6.0",
4749
"pouchdb-load": "^1.4.2",

0 commit comments

Comments
 (0)