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', 'build', '--mode', node_env, ].reject(&:empty?) end private def node_env env = ENV['NODE_ENV'] || Rails.env.to_s env = 'development' if env == 'test' env end end end end