forked from rowanmanning/pigeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjakefile.coffee
45 lines (39 loc) · 1.27 KB
/
jakefile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Dependencies
cleanCSS = require 'clean-css'
colors = require 'colors'
fs = require 'fs'
hogan = require 'hogan'
# Paths
paths =
buildConfig: './config/build.json'
header: './config/header.css'
nodebin: './node_modules/.bin'
package: './package.json'
# Build package/config
pkg = JSON.parse fs.readFileSync(paths.package, 'utf8')
pkg.year = (new Date).getFullYear()
config = JSON.parse fs.readFileSync(paths.buildConfig, 'utf8')
header = hogan.compile(fs.readFileSync(paths.header, 'utf8')).render(pkg)
# Bundle CSS
desc 'This bundles files together'
task 'bundle', ->
console.log 'Bundling CSS:'.cyan
for outPath, inPaths of config.bundle
bundle = [header]
for inPath in inPaths
content = fs.readFileSync inPath, 'utf8'
bundle.push content.trim()
fs.writeFileSync outPath, bundle.join('\n\n')
console.log "Bundled #{outPath}".green
# Minify CSS
desc 'This minifies bundled CSS files'
task 'minify', ['bundle'], ->
console.log 'Minifying CSS:'.cyan
for inPath, outPath of config.minify
content = fs.readFileSync inPath, 'utf8'
minifiedContent = cleanCSS.process content
bundle = [header, minifiedContent]
fs.writeFileSync outPath, bundle.join('\n')
console.log "Minified #{outPath}".green
# Default task
task 'default', ['minify']