Sha256: e5e1c162571b3f0da767ede085debb5e1f959ed3b8eeaeb10ffe37ad99e143f6
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
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? cleanup(site) end def self.cleanup(site) cleanup_files = site.config.dig('webpack', 'cleanup_files') if cleanup_files if Array === cleanup_files cleanup_files.each do |dest_for_clean| if Dir.exists?(File.expand_path(dest_for_clean, site.dest)) FileUtils.rm_rf(File.expand_path(dest_for_clean, site.dest)) end end else if Dir.exists?(File.expand_path(cleanup_files, site.dest)) FileUtils.rm_rf(File.expand_path(dest_src_for_clean, site.dest)) end end end 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.3 | lib/jekyll/webpack.rb |