Last active
August 29, 2015 13:58
-
-
Save bittner/9929210 to your computer and use it in GitHub Desktop.
Bootstrap-Sass JavaScript generation (combine + minify) using vanilla Compass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2014 Peter Bittner <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
system('uglifyjs --version') | |
unless $?.exitstatus == 0 | |
puts "ERROR: UglifyJS v2 not found. Please install it using \`sudo npm install -g uglify-js'" | |
puts "See https://github.com/mishoo/UglifyJS2 for more information." | |
exit 1 | |
end | |
unless defined? javascripts_dir | |
puts "ERROR: No 'javascripts_dir' defined. You should run this file with Compass (e.g. compass compile)." | |
puts "Usage: Place this file (javascript.rb) to your Compass project's folder, right" \ | |
" next to config.rb. Then add the following lines at the end of your config.rb file:" | |
puts " # JavaScript generation" | |
puts ' javascripts_before = "jquery.js another_file_before_bs.js ..."' | |
puts ' javascripts_after = "file_after_bs.js another_file_after_bs.js ..."' | |
puts " eval(File.open(File.join(File.dirname(__FILE__), 'javascript.rb')).read)" | |
exit 1 | |
end | |
# TODO | |
#. Find/compute: $(gemdir)/gems/$(bootstrap-sass-*)/vendor/assets/javascripts/bootstrap/ | |
#. Detect/use: all .js files listed in bootstrap.js (javascripts_bootstrap = "affix dropdown scrollspy ...") | |
#. Run/execute: system("uglifyjs -o scripts.js #{javascripts_before} #{javascripts_bootstrap} #{javascripts_after}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment