Skip to content

Instantly share code, notes, and snippets.

@mgrandrath
Forked from parkr/generator_scss.rb
Last active November 17, 2020 05:46
Show Gist options
  • Save mgrandrath/8282339 to your computer and use it in GitHub Desktop.
Save mgrandrath/8282339 to your computer and use it in GitHub Desktop.

Revisions

  1. Martin Grandrath revised this gist Jan 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ def initialize(site_config)
    @site_config = site_config
    end

    def generate(site)
    def generate(site)
    Dir.chdir sass_dir do
    Compass::Exec::SubCommandUI.new(%w(compile)).run!
    end
  2. Martin Grandrath revised this gist Jan 6, 2014. 1 changed file with 35 additions and 12 deletions.
    47 changes: 35 additions & 12 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -6,24 +6,47 @@
    # Place .scss files in ./_scss
    # Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
    # Config file placed in ./_sass/config.rb
    #

    require 'sass'
    require 'pathname'
    require 'compass'
    require 'compass/exec'

    module Jekyll

    class CompassGenerator < Generator
    safe true

    def generate(site)
    Dir.chdir File.expand_path('../_sass', File.dirname(__FILE__)) do
    Compass::Exec::SubCommandUI.new(%w(compile)).run!
    end
    end

    def initialize(site_config)
    super
    @site_config = site_config
    end

    def generate(site)
    Dir.chdir sass_dir do
    Compass::Exec::SubCommandUI.new(%w(compile)).run!
    end

    site.read_directories(css_path(Compass.configuration))
    end

    private

    def sass_path
    '_sass'
    end

    def sass_dir
    File.expand_path(sass_path, base_dir)
    end

    def css_path(compass_config)
    normalize(File.join(sass_path, compass_config.css_dir))
    end

    def base_dir
    @site_config[:source]
    end

    def normalize(path)
    Pathname.new(path).cleanpath.to_s
    end
    end

    end
    end
  3. @parkr parkr revised this gist Jun 5, 2012. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,6 @@
    # Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
    # Config file placed in ./_sass/config.rb
    #
    # NOTE: Currently does not function properly
    #

    require 'sass'
    require 'pathname'
  4. @parkr parkr revised this gist Jun 5, 2012. 1 changed file with 10 additions and 16 deletions.
    26 changes: 10 additions & 16 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,31 @@
    #
    # Jekyll Generator for SCSS
    #
    # (File paths relative to jekyll project root directory)
    # (File paths in this description relative to jekyll project root directory)
    # Place this file in ./_plugins
    # Place .scss files in ./_scss
    # Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
    # Config file placed in ./_config/compass.rb
    # Config file placed in ./_sass/config.rb
    #
    # NOTE: Currently does not function properly
    #

    require 'sass'
    require 'pathname'
    require 'compass'
    require 'compass/exec'

    module Jekyll

    class CompassGenerator < Generator
    safe true

    def generate(site)
    # Read in SCSS files
    scss_files = Dir[File.expand_path('../_sass/**/*.scss', File.dirname(__FILE__))]
    puts "scss_files=(#{scss_files})"
    # Convert
    options = {
    :sass_files => scss_files,
    :configuration_file => File.expand_path('../_config/compass.rb', File.dirname(__FILE__))
    }
    working_path = '../'
    compass = Compass::Commands::UpdateProject.new(working_path, options)
    # compile and write output
    compass.perform
    Dir.chdir File.expand_path('../_sass', File.dirname(__FILE__)) do
    Compass::Exec::SubCommandUI.new(%w(compile)).run!
    end
    end

    end

    end
  5. @parkr parkr revised this gist Jun 5, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,8 @@
    # Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
    # Config file placed in ./_config/compass.rb
    #
    # NOTE: Currently does not function properly
    #

    require 'compass'

  6. @parkr parkr revised this gist Jun 5, 2012. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,13 @@
    #
    # Jekyll Generator for SCSS
    #
    # (File paths relative to jekyll project root directory)
    # Place this file in ./_plugins
    # Place .scss files in ./_scss
    # Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config
    # Config file placed in ./_config/compass.rb
    #

    require 'compass'

    module Jekyll
  7. @parkr parkr created this gist Jun 5, 2012.
    25 changes: 25 additions & 0 deletions generator_scss.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    require 'compass'

    module Jekyll

    class CompassGenerator < Generator
    safe true

    def generate(site)
    # Read in SCSS files
    scss_files = Dir[File.expand_path('../_sass/**/*.scss', File.dirname(__FILE__))]
    puts "scss_files=(#{scss_files})"
    # Convert
    options = {
    :sass_files => scss_files,
    :configuration_file => File.expand_path('../_config/compass.rb', File.dirname(__FILE__))
    }
    working_path = '../'
    compass = Compass::Commands::UpdateProject.new(working_path, options)
    # compile and write output
    compass.perform
    end

    end

    end