Class: PostCssV2::Engine
- Inherits:
-
Object
- Object
- PostCssV2::Engine
- Defined in:
- lib/jekyll-postcss-v2/hook.rb
Instance Method Summary collapse
-
#initialize(source, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #process(page) ⇒ Object
Constructor Details
#initialize(source, options = {}) ⇒ Engine
Returns a new instance of Engine.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll-postcss-v2/hook.rb', line 7 def initialize(source, = {}) @script = File.([:script] || 'node_modules/.bin/postcss', source) unless File.exist?(@script) Jekyll.logger.error "PostCSS v2:", "PostCSS not found. Make sure postcss and postcss-cli are installed in your Jekyll source." Jekyll.logger.error "PostCSS v2:", "Couldn't find #{@script}" exit 1 end @config = File.([:config] || 'postcss.config.js', source) unless File.exist?(@config) Jekyll.logger.error "PostCSS v2:", "postcss.config.js not found. Make sure it exists in your Jekyll source." Jekyll.logger.error "PostCSS v2:", "Couldn't find #{@config}" exit 1 end end |
Instance Method Details
#process(page) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/jekyll-postcss-v2/hook.rb', line 30 def process(page) file_path = Pathname.new(page.site.dest + page.url) postcss_command = `#{@script} #{file_path} -r --config #{@config}` Jekyll.logger.info "PostCSS v2:", "Rewrote #{page.url} #{postcss_command}" end |