Permalink
Browse files

using less for css

  • Loading branch information...
koenpunt committed Mar 22, 2013
1 parent 29a5ac1 commit 7b7886d0d6119cb0896c2b2d7f50139e52427a20
Showing with 669 additions and 141 deletions.
  1. +35 −12 Cakefile
  2. +141 −89 chosen/chosen.css
  3. +12 −10 chosen/chosen.jquery.js
  4. +12 −10 chosen/chosen.jquery.min.js
  5. +12 −0 chosen/chosen.min.css
  6. +11 −9 chosen/chosen.proto.js
  7. +11 −9 chosen/chosen.proto.min.js
  8. +431 −0 less/chosen.less
  9. +4 −2 package.json
View
@@ -8,6 +8,14 @@ path = require 'path'
{spawn, exec} = require 'child_process'
CoffeeScript = require 'coffee-script'
{parser, uglify} = require 'uglify-js'
+less = require 'less'
+{cssmin} = require 'cssmin'
+
+stylesheets = {
+ 'chosen/chosen.css': [
+ 'less/chosen.less'
+ ]
+}
javascripts = {
'chosen/chosen.jquery.js': [
@@ -34,6 +42,10 @@ source_files = ->
for javascript, sources of javascripts
for source in sources
all_sources.push source
+
+ for stylesheet, sources of stylesheets
+ for source in sources
+ all_sources.push source
all_sources.unique()
# Get the version number
@@ -46,17 +58,19 @@ version_tag = ->
# Write chosen files with a header
#
-write_chosen_javascript = (filename, body, trailing='') ->
+write_chosen_file = (filename, body, trailing='') ->
fs.writeFileSync filename, """
-// Chosen, a Select Box Enhancer for jQuery and Protoype
-// by Patrick Filler for Harvest, http://getharvest.com
-//
-// Version #{version()}
-// Full source at https://github.com/harvesthq/chosen
-// Copyright (c) 2011 Harvest http://getharvest.com
-
-// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
-// This file is generated by `cake build`, do not edit it by hand.
+/*
+ * Chosen, a Select Box Enhancer for jQuery and Protoype
+ * by Patrick Filler for Harvest, http://getharvest.com
+ *
+ * Version #{version()}
+ * Full source at https://github.com/harvesthq/chosen
+ * Copyright (c) 2011 Harvest http://getharvest.com
+ *
+ * MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
+ * This file is generated by `cake build`, do not edit it by hand.
+ */
#{body}#{trailing}
"""
console.log "Wrote #{filename}"
@@ -72,11 +86,20 @@ task 'build', 'build Chosen from source', build = (cb) ->
file_name = source
file_contents = "#{fs.readFileSync source}"
code += CoffeeScript.compile file_contents
- write_chosen_javascript javascript, code
+ write_chosen_file javascript, code
unless process.env.MINIFY is 'false'
- write_chosen_javascript javascript.replace(/\.js$/,'.min.js'), (
+ write_chosen_file javascript.replace(/\.js$/,'.min.js'), (
uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code
), ';'
+ for stylesheet, sources of stylesheets
+ code = ''
+ for source in sources
+ file_name = source
+ code += "#{fs.readFileSync source}"
+ less.render code, (e, css) ->
+ write_chosen_file stylesheet, css
+ unless process.env.MINIFY is 'false'
+ write_chosen_file stylesheet.replace(/\.css$/,'.min.css'), cssmin(css)
package_npm () ->
package_jquery () ->
cb() if typeof cb is 'function'
Oops, something went wrong.

0 comments on commit 7b7886d

Please sign in to comment.