Sha256: b40c0a13f5782136e8ed871e2e86631adfa14aad2f491f28e1b67006ce8abb0a

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 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 in|SyntaxError/

      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

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-webpack-0.2.2 lib/jekyll/webpack.rb
jekyll-webpack-0.2.1 lib/jekyll/webpack.rb