webpack 740 B

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