Created
February 1, 2016 06:40
-
-
Save thisconnect/b2abc1d4f32f50f35fdb to your computer and use it in GitHub Desktop.
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
const postcss = require('postcss'); | |
const importCSS = require('postcss-import'); | |
const copyCSS = require('postcss-copy'); | |
const prefixCSS = require('autoprefixer'); | |
const customPropertiesCSS = require('postcss-custom-properties'); | |
const pxtoremCSS = require('postcss-pxtorem'); | |
const pixremCSS = require('pixrem'); | |
// const cssnano = require('cssnano'); | |
const fildes = require('fildes'); | |
const readFile = fildes.readFile | |
const writeFile = fildes.writeFile; | |
const input = 'src/include.css'; | |
const output = 'build/styles.css'; | |
readFile(input) | |
.then(css => { | |
return postcss([ | |
importCSS(), | |
copyCSS({ | |
'src': ['node_modules/material-design-icons/iconfont'], | |
'dest': 'build/fonts', | |
'template': '[name].[hash].[ext]', | |
'keepRelativePath': false | |
}), | |
prefixCSS({ | |
'browsers': [ | |
'android >= 4', | |
'ios >= 8', | |
'chrome >= 45', | |
'firefox >= 3.6', | |
'ie >= 8' | |
] | |
}), | |
customPropertiesCSS(), | |
pxtoremCSS(), | |
pixremCSS(), | |
// cssnano({ 'autoprefixer': false }) | |
]) | |
.process(css, { | |
'from': input, | |
'to': output, | |
'map': { | |
'inline': false | |
} | |
}) | |
}) | |
.then(result => { | |
return Promise.all([ | |
readFile('src/index.html') | |
.then(file => writeFile('build/index.html', file)), | |
writeFile(output, result.css), | |
writeFile(output + '.map', result.map) | |
]); | |
}) | |
.catch(error => { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment