blazingly fast sass compilation

This commit is contained in:
Lorin Werthen 2018-10-20 23:52:17 +02:00
parent 04461208e9
commit dffa91056f
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
5 changed files with 25 additions and 14 deletions

View file

@ -10,7 +10,7 @@ gem 'coffee-script'
gem 'icalendar' # ical files gem 'icalendar' # ical files
gem 'kramdown' gem 'kramdown'
gem 'rainpress' gem 'rainpress'
gem 'sass' gem 'sassc'
gem 'typogruby' gem 'typogruby'
# Needed for atom_feed in blogging helper # Needed for atom_feed in blogging helper

View file

@ -81,17 +81,16 @@ GEM
public_suffix (3.0.3) public_suffix (3.0.3)
rack (2.0.5) rack (2.0.5)
rainpress (1.0.1) rainpress (1.0.1)
rake (12.3.1)
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
ref (2.0.0) ref (2.0.0)
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubypants (0.7.0) rubypants (0.7.0)
sass (3.5.6) sassc (2.0.0)
sass-listen (~> 4.0.0) ffi (~> 1.9.6)
sass-listen (4.0.0) rake
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
shellany (0.0.1) shellany (0.0.1)
slow_enumerator_tools (1.1.0) slow_enumerator_tools (1.1.0)
terminal-notifier (2.0.0) terminal-notifier (2.0.0)
@ -127,7 +126,7 @@ DEPENDENCIES
nanoc nanoc
pandoc-ruby pandoc-ruby
rainpress rainpress
sass sassc
terminal-notifier terminal-notifier
terminal-notifier-guard terminal-notifier-guard
therubyracer therubyracer

18
Rules
View file

@ -164,12 +164,12 @@ end
# #
compile '/assets/scripts/**/*.coffee' do compile '/assets/scripts/**/*.coffee' do
filter :coffeescript filter :coffeescript
filter :uglify_js filter :uglify_js if production?
write ext: 'js' write ext: 'js'
end end
compile '/assets/scripts/**/*.js' do compile '/assets/scripts/**/*.js' do
filter :uglify_js, harmony: true filter :uglify_js, harmony: true if production?
end end
ignore '/assets/stylesheets/includes/**/*' ignore '/assets/stylesheets/includes/**/*'
@ -177,14 +177,22 @@ ignore '/data/**/*'
ignore '/node_modules/**/*' ignore '/node_modules/**/*'
compile '/assets/stylesheets/**/*.scss' do compile '/assets/stylesheets/**/*.scss' do
filter :sass, syntax: :scss, style: :compressed sass_opts = {
syntax: :scss,
load_paths: ['content/assets/stylesheets']
}
sass_opts[:style] = :compressed if production?
filter :sassc, sass_opts
filter :autoprefixer if production? filter :autoprefixer if production?
write ext: 'css' write ext: 'css'
end end
compile '/assets/stylesheets/**/*.css' do compile '/assets/stylesheets/**/*.css' do
filter :rainpress if production?
filter :autoprefixer if production? filter :rainpress
filter :autoprefixer
end
write ext: 'css' write ext: 'css'
end end

View file

@ -1,7 +1,7 @@
@import "includes/variables"; @import "includes/variables";
@import "../../../node_modules/bulma/bulma"; @import "node_modules/bulma/bulma";
@import "../../../node_modules/bulma-divider/divider"; @import "node_modules/bulma-divider/divider";
.nav-right { .nav-right {
flex: none; flex: none;

4
lib/filters/sassc.rb Normal file
View file

@ -0,0 +1,4 @@
require 'sassc'
Nanoc::Filter.define(:sassc) do |content, params|
SassC::Engine.new(content, params).render
end