Skip to content

Commit

Permalink
Precompile assets on release to get rid of bootstrap runtime dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Mar 18, 2016
1 parent e79a0e6 commit f1c8013
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.gem
*.css
.bundle
Gemfile.lock
pkg/*
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ notifications:
email: false
slack:
secure: crOO1QGnFn9T1DpVgxkukTSiN8lQq09X8WF8oi1Eoa7Liex4gzWq7f8wlIXPrRFAsNjU47fSrz+L1C6Eg068Vd2df9pkqjW0pLNeqUViJ35TzpYISTtzJrX+x3nvCQLlvS4leP6lkijlsvlu1IN0xnXadW5cmcMoEcPo4Yma1RUklwlreSRIEmJiutYKVFRw3gIZA9vsnXNEcD408mvSY/8Kuw+hmRQupODUalXDpZo1q3HH+ZPQq+/rGuJ7XRf9sBtxjpUF0G4FJZQhVP4CrLNYVBE/83rHJ6HSf6u3SlYVIMiautq0nWpVLPHUrkOPJVeVh6EPtoFeI/cehH1NyoAVvL5a39wFRBlJ4jVPWUrrnihJT/6+P6GM9PSnYogxtIoTsdrYES2FgtWGgwG5uLyw8U6bW7G7rCzQwBP7enVHWVCbDgdSSjE1Mg1I9qhRuL6pHs5des4VKk6pfD3p+BRqLmOZR2jx4v8MFwakSFqQWOMxaD0U1lfxecqSx9OkwWEhCFSnHeXeHInEhY6qKCdZZzT+beYn0xppUMPJGMTqe5+po8gL+5MxQwI8Xs/5hSve5frfmuS7UQf5BnFMOzwoThQrXCFRz58wXvcZTD9eTdVBV44Hsi5OLdYn9K58sNUhgcxGfRgdE7Gy9P7DD4fHPGakD/Tz++HuCmCUXNs=
before_deploy: rake assets:compile
deploy:
provider: rubygems
api_key:
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source "https://rubygems.org"
gemspec

gem "bootstrap", "= 4.0.0.alpha3"

group :test do
version = ENV["RAILS_VERSION"] || "master"
if version == "master"
Expand Down
23 changes: 23 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,26 @@ Rake::TestTask.new("test:integration") do |test|
end

task default: :test

namespace :assets do
stylesheets_path = "app/assets/stylesheets"
stylesheet_file = "flipflop.css"
stylesheet_path = stylesheets_path + "/" + stylesheet_file

task :compile do
require "bundler/setup"
require "flipflop"
require "sprockets"
require "bootstrap"

environment = Sprockets::Environment.new
environment.append_path stylesheets_path
environment.append_path Bootstrap.stylesheets_path
environment.css_compressor = :scss
File.write(stylesheet_path, environment[stylesheet_file])
end

task :clean do
FileUtils.rm(stylesheet_path)
end
end
15 changes: 14 additions & 1 deletion app/assets/stylesheets/flipflop.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
$enable-transitions: true;
@import "bootstrap";

@import "bootstrap/variables";
@import "bootstrap/mixins";
@import "bootstrap/normalize";
@import "bootstrap/print";

@import "bootstrap/reboot";
@import "bootstrap/type";
@import "bootstrap/grid";
@import "bootstrap/tables";
@import "bootstrap/buttons";

@import "bootstrap/button-group";
@import "bootstrap/labels";

section.flipflop {
@extend .container-fluid;
Expand Down
4 changes: 2 additions & 2 deletions app/views/flipflop/features/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
<%= submit_tag "on",
type: "submit",
class: @feature_set.strategy_status(strategy, feature) == "on" ? "active" : nil,
disabled: strategy.switchable? ? false : true
disabled: !strategy.switchable?
-%>

<%= submit_tag "off",
type: "submit",
class: @feature_set.strategy_status(strategy, feature) == "off" ? "active" : nil,
disabled: strategy.switchable? ? false : true
disabled: !strategy.switchable?
-%>
</div>
<% end -%>
Expand Down
3 changes: 1 addition & 2 deletions flipflop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ Gem::Specification.new do |s|
s.description = %q{Declarative API for specifying features, switchable in declaration, database and cookies.}
s.license = "MIT"

s.files = `git ls-files`.split("\n")
s.files = `git ls-files`.split("\n").map { |f| f.sub(".scss", ".css") }
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency("activesupport", ">= 4.0")
s.add_dependency("bootstrap", "~> 4.0.0.alpha3")
end

0 comments on commit f1c8013

Please sign in to comment.