about summary refs log tree commit diff
path: root/bin/webpack-dev-server
diff options
context:
space:
mode:
authorSurinna Curtis <ekiru.0@gmail.com>2017-11-16 01:38:26 -0600
committerGitHub <noreply@github.com>2017-11-16 01:38:26 -0600
commitee560abdbe7a2caf0f7ac6137faf248bbaff9a93 (patch)
treefcd9bdb5ba49ab7a6a79590c74db858ae77b4239 /bin/webpack-dev-server
parent88627fd7aa2493a6890d60a5965459e4c7fe6fe9 (diff)
parent35fbdc36f92b610e8a73e2acb220e87cf5fc83b0 (diff)
Merge pull request #216 from glitch-soc/merge-upstream-3023725
Merge upstream at commit 3023725
Diffstat (limited to 'bin/webpack-dev-server')
-rwxr-xr-xbin/webpack-dev-server83
1 files changed, 16 insertions, 67 deletions
diff --git a/bin/webpack-dev-server b/bin/webpack-dev-server
index c9672f663..cf701102a 100755
--- a/bin/webpack-dev-server
+++ b/bin/webpack-dev-server
@@ -1,68 +1,17 @@
 #!/usr/bin/env ruby
-$stdout.sync = true
-
-require "shellwords"
-require "yaml"
-require "socket"
-
-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__)
-CONFIG_FILE       = File.join(APP_PATH, "config/webpacker.yml")
-NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
-WEBPACK_CONFIG    = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")
-
-DEFAULT_LISTEN_HOST_ADDR = NODE_ENV == 'development' ? 'localhost' : '0.0.0.0'
-
-def args(key)
-  index = ARGV.index(key)
-  index ? ARGV[index + 1] : nil
-end
-
-begin
-  dev_server = YAML.load_file(CONFIG_FILE)[RAILS_ENV]["dev_server"]
-
-  HOSTNAME          = args('--host') || dev_server["host"]
-  PORT              = args('--port') || dev_server["port"]
-  HTTPS             = ARGV.include?('--https') || dev_server["https"]
-  DEV_SERVER_ADDR   = "http#{"s" if HTTPS}://#{HOSTNAME}:#{PORT}"
-  LISTEN_HOST_ADDR  = args('--listen-host') || DEFAULT_LISTEN_HOST_ADDR
-
-rescue Errno::ENOENT, NoMethodError
-  $stdout.puts "Webpack dev_server configuration not found in #{CONFIG_FILE}."
-  $stdout.puts "Please run bundle exec rails webpacker:install to install webpacker"
-  exit!
-end
-
-begin
-  server = TCPServer.new(LISTEN_HOST_ADDR, PORT)
-  server.close
-
-rescue Errno::EADDRINUSE
-  $stdout.puts "Another program is running on port #{PORT}. Set a new port in #{CONFIG_FILE} for dev_server"
-  exit!
-end
-
-# Delete supplied host, port and listen-host CLI arguments
-["--host", "--port", "--listen-host"].each do |arg|
-  ARGV.delete(args(arg))
-  ARGV.delete(arg)
-end
-
-env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
-
-cmd = [
-  "#{NODE_MODULES_PATH}/.bin/webpack-dev-server", "--progress", "--color",
-  "--config", WEBPACK_CONFIG,
-  "--host", LISTEN_HOST_ADDR,
-  "--public", "#{HOSTNAME}:#{PORT}",
-  "--port", PORT.to_s
-] + ARGV
-
-Dir.chdir(APP_PATH) do
-  exec env, *cmd
-end
+# frozen_string_literal: true
+#
+# This file was generated by Bundler.
+#
+# The application 'webpack-dev-server' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+  Pathname.new(__FILE__).realpath)
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("webpacker", "webpack-dev-server")