Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added css minification to Cakefile (#1093) #1102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions Cakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ path = require 'path'
{spawn, exec} = require 'child_process' {spawn, exec} = require 'child_process'
CoffeeScript = require 'coffee-script' CoffeeScript = require 'coffee-script'
{parser, uglify} = require 'uglify-js' {parser, uglify} = require 'uglify-js'
{cssmin} = require 'cssmin'

stylesheets = {
'chosen/chosen.css': [
'css/chosen.css'
]
}


javascripts = { javascripts = {
'chosen/chosen.jquery.js': [ 'chosen/chosen.jquery.js': [
Expand All @@ -34,6 +41,10 @@ source_files = ->
for javascript, sources of javascripts for javascript, sources of javascripts
for source in sources for source in sources
all_sources.push source all_sources.push source

for stylesheet, sources of stylesheets
for source in sources
all_sources.push source
all_sources.unique() all_sources.unique()


# Get the version number # Get the version number
Expand All @@ -46,17 +57,19 @@ version_tag = ->


# Write chosen files with a header # Write chosen files with a header
# #
write_chosen_javascript = (filename, body, trailing='') -> write_chosen_file = (filename, body, trailing='') ->
fs.writeFileSync filename, """ fs.writeFileSync filename, """
// Chosen, a Select Box Enhancer for jQuery and Protoype /*
// by Patrick Filler for Harvest, http://getharvest.com * 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 * Version #{version()}
// Copyright (c) 2011 Harvest http://getharvest.com * 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. * 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} #{body}#{trailing}
""" """
console.log "Wrote #{filename}" console.log "Wrote #{filename}"
Expand All @@ -72,11 +85,21 @@ task 'build', 'build Chosen from source', build = (cb) ->
file_name = source file_name = source
file_contents = "#{fs.readFileSync source}" file_contents = "#{fs.readFileSync source}"
code += CoffeeScript.compile file_contents code += CoffeeScript.compile file_contents
write_chosen_javascript javascript, code write_chosen_file javascript, code
unless process.env.MINIFY is 'false' 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 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
file_contents = "#{fs.readFileSync source}"
code += file_contents
write_chosen_file stylesheet, code
unless process.env.MINIFY is 'false'
write_chosen_file stylesheet.replace(/\.css$/,'.min.css'), cssmin(code)
package_npm () -> package_npm () ->
package_jquery () -> package_jquery () ->
cb() if typeof cb is 'function' cb() if typeof cb is 'function'
Expand Down
11 changes: 11 additions & 0 deletions chosen/chosen.css
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* Chosen, a Select Box Enhancer for jQuery and Protoype
* by Patrick Filler for Harvest, http://getharvest.com
*
* Version 0.9.12
* 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.
*/
/* @group Base */ /* @group Base */
.chzn-container { .chzn-container {
font-size: 13px; font-size: 13px;
Expand Down
22 changes: 12 additions & 10 deletions chosen/chosen.jquery.js
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,14 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype /*
// by Patrick Filler for Harvest, http://getharvest.com * Chosen, a Select Box Enhancer for jQuery and Protoype
// * by Patrick Filler for Harvest, http://getharvest.com
// Version 0.9.12 *
// Full source at https://github.com/harvesthq/chosen * Version 0.9.12
// Copyright (c) 2011 Harvest http://getharvest.com * 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. * MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
* This file is generated by `cake build`, do not edit it by hand.
*/
(function() { (function() {
var SelectParser; var SelectParser;


Expand Down Expand Up @@ -331,7 +333,7 @@ Copyright (c) 2011 by Harvest
__extends(Chosen, _super); __extends(Chosen, _super);


function Chosen() { function Chosen() {
Chosen.__super__.constructor.apply(this, arguments); return Chosen.__super__.constructor.apply(this, arguments);
} }


Chosen.prototype.setup = function() { Chosen.prototype.setup = function() {
Expand Down
22 changes: 12 additions & 10 deletions chosen/chosen.jquery.min.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions chosen/chosen.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions chosen/chosen.proto.js
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,14 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype /*
// by Patrick Filler for Harvest, http://getharvest.com * Chosen, a Select Box Enhancer for jQuery and Protoype
// * by Patrick Filler for Harvest, http://getharvest.com
// Version 0.9.12 *
// Full source at https://github.com/harvesthq/chosen * Version 0.9.12
// Copyright (c) 2011 Harvest http://getharvest.com * 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. * MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
* This file is generated by `cake build`, do not edit it by hand.
*/
(function() { (function() {
var SelectParser; var SelectParser;


Expand Down
20 changes: 11 additions & 9 deletions chosen/chosen.proto.min.js

Large diffs are not rendered by default.

Loading