-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.js
23 lines (18 loc) · 935 Bytes
/
builder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import fs from 'fs'
import postcss from 'postcss'
import pImport from 'postcss-import'
import pDuplicated from 'postcss-combine-duplicated-selectors'
import pComments from 'postcss-discard-comments'
import pAutoprefixer from 'autoprefixer'
import pMinify from 'postcss-minify'
const [from, to] = ['src/all.css', 'helpers.css']
const css = fs.readFileSync(from, 'utf8')
const packageFile = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const title = packageFile.name + ' ' + packageFile.version
const license = packageFile.license + ' License'
const link = packageFile.repository.url.replace('git+', '').replace('.git', '')
const header = '/*! ' + [title, license, link].join(' | ') + ' */'
const plugins = [pImport, pAutoprefixer, pDuplicated({ removeDuplicatedProperties: true }), pComments, pMinify]
postcss(plugins)
.process(css, { from })
.then(({ css }) => fs.writeFile(to, [header, css].join('\n\n'), () => true))