You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
717 B

  1. #!/usr/bin/env ruby
  2. $stdout.sync = true
  3. require "shellwords"
  4. ENV["RAILS_ENV"] ||= "development"
  5. RAILS_ENV = ENV["RAILS_ENV"]
  6. ENV["NODE_ENV"] ||= RAILS_ENV
  7. NODE_ENV = ENV["NODE_ENV"]
  8. APP_PATH = File.expand_path("../", __dir__)
  9. NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
  10. WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")
  11. unless File.exist?(WEBPACK_CONFIG)
  12. puts "Webpack configuration not found."
  13. puts "Please run bundle exec rails webpacker:install to install webpacker"
  14. exit!
  15. end
  16. env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
  17. cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV
  18. Dir.chdir(APP_PATH) do
  19. exec env, *cmd
  20. end