The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

34 lines
996 B

  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. CONFIG_PATH = File.join(APP_PATH, "config/webpack/paths.yml")
  11. begin
  12. paths = YAML.load(File.read(CONFIG_PATH))[NODE_ENV]
  13. NODE_MODULES_PATH = File.join(APP_PATH.shellescape, paths["node_modules"])
  14. WEBPACK_CONFIG_PATH = File.join(APP_PATH.shellescape, paths["config"])
  15. rescue Errno::ENOENT, NoMethodError
  16. puts "Configuration not found in config/webpack/paths.yml"
  17. puts "Please run bundle exec rails webpacker:install to install webpacker"
  18. exit!
  19. end
  20. WEBPACK_BIN = "#{NODE_MODULES_PATH}/.bin/webpack"
  21. WEBPACK_CONFIG = "#{WEBPACK_CONFIG_PATH}/#{NODE_ENV}.js"
  22. Dir.chdir(APP_PATH) do
  23. exec "NODE_PATH=#{NODE_MODULES_PATH} #{WEBPACK_BIN} --config #{WEBPACK_CONFIG}" \
  24. " #{ARGV.join(" ")}"
  25. end