Skip to content

Commit

Permalink
fix: remove middleman-sprockets and govuk_template
Browse files Browse the repository at this point in the history
middleman-sprockets is deprecated[1] so remove all of our terrible
hacks and stick with SASS import statements. Remove the hard
dependency on SASS as well since Middleman ships with it. Remove the
govuk_template dependency as we don't use it either.

This will also make the bundle smaller and faster (the node_modules
folder is +8M smaller).

[1]: middleman/middleman-sprockets#132 (comment)
  • Loading branch information
freesteph committed Feb 20, 2020
1 parent 30e3efe commit c8c9da6
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 1,218 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
# Middleman Gems
gem 'middleman', '>= 4.0.0'
gem 'middleman-livereload'
gem "middleman-sprockets"
gem 'sprockets', '4.0.0'
gem 'sass'
gem 'sassc'
15 changes: 0 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ GEM
em-websocket (~> 0.5.1)
middleman-core (>= 3.3)
rack-livereload (~> 0.3.15)
middleman-sprockets (4.1.1)
middleman-core (~> 4.0)
sprockets (>= 3.0)
minitest (5.11.3)
padrino-helpers (0.13.3.4)
i18n (~> 0.6, >= 0.6.7)
Expand All @@ -92,17 +89,9 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sassc (2.2.1)
ffi (~> 1.9)
servolux (0.13.0)
sprockets (4.0.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
temple (0.8.1)
thor (0.20.3)
thread_safe (0.3.6)
Expand All @@ -118,10 +107,6 @@ PLATFORMS
DEPENDENCIES
middleman (>= 4.0.0)
middleman-livereload
middleman-sprockets
sass
sassc
sprockets (= 4.0.0)
tzinfo-data
wdm (~> 0.1.0)

Expand Down
42 changes: 0 additions & 42 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,3 @@ def get_nav_active_class(url, root_scope)
'govuk-header__navigation-item--active' if current_page.url.start_with? (root_scope or url)
end
end

# Build-specific configuration
configure :build do
# Minify CSS on build
# activate :minify_css

# Minify Javascript on build
# activate :minify_javascript
end

# Override generated asset path to remove the long explicit vendor paths
class ImportedAssetPathProcessor
attr_reader :app

def initialize(app)
@app = app
end

def call(sprockets_asset)
filename = File.basename(sprockets_asset.logical_path)
directory = case sprockets_asset.logical_path
# I fought the asset pipeline and the asset pipeline won:
# This first `when` statement handles an edge case where images are nested inside
# a stylesheets directory, as is the case in govuk_template.
when /stylesheets\/images\// then ([app.config[:images_dir]] * 2).join('/')
when /images\// then app.config[:images_dir]
when /fonts\// then app.config[:fonts_dir]
when /stylesheets\// then app.config[:css_dir]
else
"assets"
end

File.join(directory, filename)
end
end

activate :sprockets do |config|
config.expose_middleman_helpers = true
config.imported_asset_path = ImportedAssetPathProcessor.new(app)
end

sprockets.append_path File.join(root, "node_modules")
Loading

0 comments on commit c8c9da6

Please sign in to comment.