Sha256: 5407e2ba85cf96360b6e211a6c1aedcca32438292ae5f1356286be7eb6fac09e

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby
require 'shellwords'

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__)
ESCAPED_APP_PATH = APP_PATH.shellescape

SET_NODE_PATH  = "NODE_PATH=#{ESCAPED_APP_PATH}/node_modules"
WEBPACKER_BIN  = "./node_modules/.bin/webpack-dev-server"
WEBPACK_CONFIG = "#{ESCAPED_APP_PATH}/config/webpack/#{NODE_ENV}.js"

# Warn the user if the configuration is not set
RAILS_ENV_CONFIG = File.join("config", "environments", "#{RAILS_ENV}.rb")

# Look into the environment file for a non-commented variable declaration
unless File.foreach(File.join(APP_PATH, RAILS_ENV_CONFIG)).detect { |line| line.match(/^\s*[^#]*config\.x\.webpacker\[\:dev_server_host\].*=/) }
  puts "Warning: if you want to use webpack-dev-server, you need to tell Webpacker to serve asset packs from it. Please set config.x.webpacker[:dev_server_host] in #{RAILS_ENV_CONFIG}.\n\n"
end

Dir.chdir(APP_PATH) do
  exec "#{SET_NODE_PATH} #{WEBPACKER_BIN} --config #{WEBPACK_CONFIG} --content-base #{ESCAPED_APP_PATH}/public/packs #{ARGV.join(" ")}"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
railman-1.0.3 templates/rails_app/bin/webpack-dev-server
railman-1.0.2 templates/rails_app/bin/webpack-dev-server
railman-1.0.1 templates/rails_app/bin/webpack-dev-server
railman-1.0.0 templates/rails_app/bin/webpack-dev-server