Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ spec/dest
.bridgetown-metadata
.bridgetown-cache
.bridgetown-webpack

.env
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ gemspec
gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]

group :development, :test do
gem "rubocop", "~> 0.81.0"
gem "rubocop"
end
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@
Run this command to add this plugin to your site's Gemfile:

```shell
bundle add bridgetown-minify-html -g bridgetown_plugins
bundle add bridgetown-minify-html
```

Or simply add this line to your Gemfile:

```ruby
gem 'bridgetown-minify-html'
```

And then add the initializer to your configuration in `config/initializers.rb`:

```ruby
init :"bridgetown-minify-html"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions bridgetown-minify-html.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 2.7"

spec.add_dependency "bridgetown", ">= 1.0.0", "< 2.0"
spec.add_dependency "bridgetown", ">= 1.2.0", "< 2.0"
spec.add_dependency "htmlcompressor", ">= 0.4", "< 1.0"

spec.add_development_dependency "bundler"
spec.add_development_dependency "nokogiri", "~> 1.6"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
end
4 changes: 4 additions & 0 deletions lib/bridgetown-minify-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
require "htmlcompressor"
require "bridgetown-minify-html/builder"
require "bridgetown-minify-html/minifier"

Bridgetown.initializer :"bridgetown-minify-html" do |config|
config.builder BridgetownMinifyHtml::Builder
end
2 changes: 0 additions & 2 deletions lib/bridgetown-minify-html/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ def build
end
end
end

BridgetownMinifyHtml::Builder.register
1 change: 1 addition & 0 deletions spec/bridgetown-minify-html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
let(:page_contents) { File.read(dest_dir("index.html")) }
let(:post_contents) { File.read(dest_dir("2020/07/20/sample/index.html")) }
before(:each) do
config.run_initializers! context: :static
site.process
end

Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/config/initializers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

Bridgetown.configure do |config|
init :'bridgetown-minify-html'
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

require "bridgetown"

Bridgetown.begin!

require File.expand_path("../lib/bridgetown-minify-html", __dir__)

Bridgetown.logger.log_level = :error
Expand Down