Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Using less for css #1103

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+669 −141
Split
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.