Sha256: 92001e9567db6dd671a0bb4a883212c5ca71d5ffbe9151aed74bfc07e174e8a0

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

require "jekyll/webpack/version"
require "jekyll"
require "open3"

module Jekyll
  module Webpack
    class Error < StandardError; end

    def self.build(site)
      site_dest = site.dest

      stdout, stderr, status = Open3.capture3(
        "../node_modules/.bin/webpack",
        chdir: File.expand_path(site_dest)
      )

      runtime_error = stdout =~ /error/i

      raise Error, stderr if stderr.size > 0
      raise Error, stdout if !runtime_error.nil?
    end
  end
end

Jekyll::Hooks.register :site, :post_write do |site|
  Jekyll::Webpack.build(site)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-webpack-0.2.0 lib/jekyll/webpack.rb