2017-05-03 02:04:16 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
$stdout.sync = true
|
|
|
|
|
|
|
|
require "shellwords"
|
|
|
|
|
|
|
|
ENV["RAILS_ENV"] ||= "development"
|
2017-06-18 02:57:09 +02:00
|
|
|
RAILS_ENV = ENV["RAILS_ENV"]
|
2017-05-03 02:04:16 +02:00
|
|
|
|
|
|
|
ENV["NODE_ENV"] ||= RAILS_ENV
|
2017-06-18 02:57:09 +02:00
|
|
|
NODE_ENV = ENV["NODE_ENV"]
|
2017-05-03 02:04:16 +02:00
|
|
|
|
2017-06-18 02:57:09 +02:00
|
|
|
APP_PATH = File.expand_path("../", __dir__)
|
|
|
|
NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
|
|
|
|
WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")
|
2017-05-03 02:04:16 +02:00
|
|
|
|
2017-06-18 02:57:09 +02:00
|
|
|
unless File.exist?(WEBPACK_CONFIG)
|
|
|
|
puts "Webpack configuration not found."
|
2017-05-03 02:04:16 +02:00
|
|
|
puts "Please run bundle exec rails webpacker:install to install webpacker"
|
|
|
|
exit!
|
|
|
|
end
|
|
|
|
|
2017-09-27 14:41:54 +02:00
|
|
|
env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
|
|
|
|
cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV
|
2017-05-03 02:04:16 +02:00
|
|
|
|
|
|
|
Dir.chdir(APP_PATH) do
|
2017-09-27 14:41:54 +02:00
|
|
|
exec env, *cmd
|
2017-05-03 02:04:16 +02:00
|
|
|
end
|