Sha256: 58010c42ae1896c9feed6f60346cf2fb7717bf1ba194445c7c4772b335827568

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

<%= shebang %>
$stdout.sync = true

require "shellwords"
require "yaml"

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_PATH            = File.join(APP_PATH, "config/webpack/paths.yml")
DEV_SERVER_CONFIG_PATH = File.join(APP_PATH, "config/webpack/development.server.yml")

begin
  paths            = YAML.load(File.read(CONFIG_PATH))
  dev_server = YAML.load(File.read(DEV_SERVER_CONFIG_PATH))

  NODE_MODULES_PATH   = File.join(APP_PATH.shellescape, paths["node_modules"])
  WEBPACK_CONFIG_PATH = File.join(APP_PATH.shellescape, paths["config"])

  if NODE_ENV == "development" && dev_server["enabled"]
    puts "Warning: webpack-dev-server is currently enabled in #{DEV_SERVER_CONFIG_PATH}. " \
      "Disable to serve assets directly from public/packs directory"
  end
rescue Errno::ENOENT, NoMethodError
  puts "Configuration not found in config/webpack/paths.yml or config/webpack/development.server.yml."
  puts "Please run bundle exec rails webpacker:install to install webpacker"
  exit!
end

WEBPACK_BIN    = "#{NODE_MODULES_PATH}/.bin/webpack"
WEBPACK_CONFIG = "#{WEBPACK_CONFIG_PATH}/#{NODE_ENV}.js"

Dir.chdir(APP_PATH) do
  exec "NODE_PATH=#{NODE_MODULES_PATH} #{WEBPACK_BIN} --config #{WEBPACK_CONFIG}" \
    " #{ARGV.join(" ")}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webpacker-1.1 lib/install/bin/webpack.tt