pages
Version:
AngularJS / Node.js sidekick.
61 lines (33 loc) • 1.74 kB
text/coffeescript
utils = require '../../lib/utils'
notify = require '../../lib/notify'
log = require '../../lib/log'
sources = require './sources'
notifications = require './notifications'
build = (cb) ->
css = []
First, add the CSS we chose _not_ to remove from the vendor mappings in `bower.json`. Since CSS isn't compiled here, no need to separate this.
Array::push.apply css, sources.vendor.compile.css().map (dependency) -> dependency.file
List the local CSS files (it's assumed we're using all of these).
utils.listFiles "#{process.cwd()}/css", '.css', (appCSS) ->
Array::push.apply css, appCSS
If we do not have any CSS (the default skeleton, for example) no need to concat/minify.
return cb() if css.length is 0
switch process.env.NODE_ENV
In `development`, we just concat all CSS into a single file.
when 'development'
utils.concatFiles css, "#{process.cwd()}/_app/compiled/app.css", (error) ->
notifications.compiler error if error
global.pages.assets.css.push 'compiled/app.css'
cb()
In `production`, we additionally minify the single file.
when 'production'
utils.concatFiles css, "#{process.cwd()}/_app/compiled/app.css", (error) ->
notifications.compiler error if error
utils.concatMinifyFile 'css', "#{process.cwd()}/_app/compiled/app.css", "#{process.cwd()}/_app/compiled/app.min.css", (error) ->
notifications.compiler error if error
global.pages.assets.css.push 'compiled/app.min.css'
cb()
## Public API ##
publicFns =
build: build
module.exports = publicFns