Sha256: d8e2fcf476fcec0e962203b0ff95546d53e00bd42630482da29050e03eb27c51

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

module SewingKit
  module Webpack
    class Compiler
      def compile
        result = Kernel.system(
          { 'NODE_ENV' => node_env },
          *command,
          chdir: Rails.root.to_s,
          out: $stdout,
          err: $stderr,
        )

        if !result
          puts "sewing-kit compile failed with error code #{$?}"
          exit(1)
        end
        result
      end

      private

      def command
        [
          'node_modules/.bin/sewing-kit',
          'compile',
          '--config-file',
          'config/sewing-kit.config.js',
          '--target',
          'client',
          '--env',
          node_env,
        ].reject(&:empty?)
      end

      private
      def node_env
        ENV['NODE_ENV'] || Rails.env.to_s
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sewing_kit-0.4.6 lib/sewing_kit/webpack/compiler.rb