#!/usr/bin/env ruby require 'shellwords' ENV['RAILS_ENV'] ||= 'development' RAILS_ENV = ENV['RAILS_ENV'] ENV['NODE_ENV'] ||= RAILS_ENV NODE_ENV = ENV['NODE_ENV'] APP_PATH = File.expand_path('../', __dir__) ESCAPED_APP_PATH = APP_PATH.shellescape SET_NODE_PATH = "NODE_PATH=#{ESCAPED_APP_PATH}/node_modules" WEBPACK_BIN = "./node_modules/webpack/bin/webpack.js" WEBPACK_CONFIG = "#{ESCAPED_APP_PATH}/config/webpack/#{NODE_ENV}.js" Dir.chdir(APP_PATH) do exec "#{SET_NODE_PATH} #{WEBPACK_BIN} --config #{WEBPACK_CONFIG} #{ARGV.join(" ")}" end