Skip to content

Commit

Permalink
Merge pull request #2176 from alphagov/use-sassc-for-assets
Browse files Browse the repository at this point in the history
Use SassC to compile Sass
  • Loading branch information
boffbowsh committed May 18, 2015
2 parents a141931 + b92605b commit b5dc153
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ else
end

gem 'sass', '3.4.9'
gem 'sass-rails'
gem 'sass-rails' # required by bootstrap-sass, but not listed as a dependency of it
gem 'sassc-rails', github: 'bolandrm/sassc-rails', branch: 'master'
gem 'uglifier'

group :development, :test do
Expand Down
18 changes: 17 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ GIT
test_track (0.1.0)
rails (>= 3.1.0)

GIT
remote: git://github.com/bolandrm/sassc-rails.git
revision: cac614328c2830646dc9d1ee218caf6204b8e0c8
branch: master
specs:
sassc-rails (0.0.9)
rails (>= 4.0.0)
sass
sassc (~> 1.2.0)
sprockets (> 2.11)
tilt

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -338,12 +350,15 @@ GEM
sanitize (2.1.0)
nokogiri (>= 1.4.4)
sass (3.4.9)
sass-rails (5.0.1)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sassc (1.2.0)
bundler
ffi (~> 1.9.6)
shared_mustache (0.2.0)
execjs (>= 1.2.4)
mustache (~> 0.99.4)
Expand Down Expand Up @@ -489,6 +504,7 @@ DEPENDENCIES
rummageable (= 1.2.0)
sass (= 3.4.9)
sass-rails
sassc-rails!
shared_mustache (~> 0.2.0)
sidekiq (~> 3.3.0)
sidekiq-logging-json (= 0.0.14)
Expand Down
20 changes: 10 additions & 10 deletions app/assets/stylesheets/admin/govuk_admin_template/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
}

@mixin add-top-margin($important: "") {
margin-top: $default-vertical-margin #{$important};
margin-top: $default-vertical-margin unquote($important);
}

@mixin remove-top-margin($important: "") {
margin-top: 0 #{$important};
margin-top: 0 unquote($important);
}

@mixin add-bottom-margin($important: "") {
margin-bottom: $default-vertical-margin #{$important};
margin-bottom: $default-vertical-margin unquote($important);
}

@mixin remove-bottom-margin($important: "") {
margin-bottom: 0 #{$important};
margin-bottom: 0 unquote($important);
}

@mixin add-right-margin($important: "") {
margin-right: $default-horizontal-margin #{$important};
margin-right: $default-horizontal-margin unquote($important);
}

@mixin add-left-margin($important: "") {
margin-left: $default-horizontal-margin #{$important};
margin-left: $default-horizontal-margin unquote($important);
}

@mixin add-right-gutter($important: "") {
margin-right: $default-horizontal-margin * 2 #{$important};
margin-right: $default-horizontal-margin * 2 unquote($important);
}

@mixin add-left-gutter($important: "") {
margin-left: $default-horizontal-margin * 2 #{$important};
margin-left: $default-horizontal-margin * 2 unquote($important);
}

@mixin add-label-margin {
Expand All @@ -45,9 +45,9 @@
}

@mixin add-top-padding($important: "") {
padding-top: $default-vertical-padding #{$important};
padding-top: $default-vertical-padding unquote($important);
}

@mixin add-bottom-padding($important: "") {
padding-bottom: $default-vertical-padding #{$important};
padding-bottom: $default-vertical-padding unquote($important);
}
22 changes: 22 additions & 0 deletions config/initializers/sassc_rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# As recommended in https://github.com/bolandrm/sassc-rails/issues/6#issuecomment-100949872
require "sprockets/engines"

module Extensions
module Sprockets
module Engines
def register_engine(ext, klass)
return if [
Sass::Rails::SassTemplate,
Sass::Rails::ScssTemplate
].include?(klass)

super
end
end
end
end

Sprockets::Base.send(:prepend, Extensions::Sprockets::Engines)

Rails.application.assets.register_engine '.sass', SassC::Rails::SassTemplate
Rails.application.assets.register_engine '.scss', SassC::Rails::ScssTemplate

0 comments on commit b5dc153

Please sign in to comment.