diff --git a/lib/github-pages/configuration.rb b/lib/github-pages/configuration.rb index ddcd0668..fa38a159 100644 --- a/lib/github-pages/configuration.rb +++ b/lib/github-pages/configuration.rb @@ -24,11 +24,12 @@ class Configuration }, }.freeze - # Jekyll defaults merged with Pages defaults. - MERGED_DEFAULTS = Jekyll::Utils.deep_merge_hashes( - Jekyll::Configuration::DEFAULTS, - DEFAULTS - ).freeze + # User-overwritable defaults used only in production for practical reasons + PRODUCTION_DEFAULTS = Jekyll::Utils.deep_merge_hashes DEFAULTS, { + "sass" => { + "style" => "compressed", + }, + }.freeze # Options which GitHub Pages sets, regardless of the user-specified value # @@ -82,6 +83,11 @@ def development? Jekyll.env == "development" end + def defaults_for_env + defaults = development? ? DEFAULTS : PRODUCTION_DEFAULTS + Jekyll::Utils.deep_merge_hashes Jekyll::Configuration::DEFAULTS, defaults + end + # Given a user's config, determines the effective configuration by building a user # configuration sandwhich with our overrides overriding the user's specified # values which themselves override our defaults. @@ -91,7 +97,7 @@ def development? # Note: this is a highly modified version of Jekyll#configuration def effective_config(user_config) # Merge user config into defaults - config = Jekyll::Utils.deep_merge_hashes(MERGED_DEFAULTS, user_config) + config = Jekyll::Utils.deep_merge_hashes(defaults_for_env, user_config) .fix_common_issues .add_default_collections diff --git a/spec/github-pages/configuration_spec.rb b/spec/github-pages/configuration_spec.rb index 060a7319..72c9dcdc 100644 --- a/spec/github-pages/configuration_spec.rb +++ b/spec/github-pages/configuration_spec.rb @@ -14,6 +14,8 @@ let(:configuration) { Jekyll.configuration(test_config) } let(:site) { Jekyll::Site.new(configuration) } let(:effective_config) { described_class.effective_config(site.config) } + let(:defaults_for_env) { described_class.defaults_for_env } + before(:each) do ENV.delete("DISABLE_WHITELIST") ENV["JEKYLL_ENV"] = "test" @@ -55,6 +57,15 @@ it "accepts local configs" do expect(effective_config["testing"]).to eql("123") end + + context "in development" do + before { ENV["JEKYLL_ENV"] = "development" } + + it "doesn't compress sass" do + expect(effective_config["sass"]).to be_nil + expect(defaults_for_env["sass"]).to be_nil + end + end end context "#set being called via the hook" do @@ -159,6 +170,11 @@ expect(described_class.disable_whitelist?).to eql(false) end end + + it "compresses sass" do + expect(effective_config["sass"]).to eql("style" => "compressed") + expect(defaults_for_env["sass"]).to eql("style" => "compressed") + end end end end