Class: Webpacker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/webpacker/runner.rb

Direct Known Subclasses

DevServerRunner, WebpackRunner

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/webpacker/runner.rb', line 9

def initialize(argv)
  @argv = argv

  @app_path              = File.expand_path(".", Dir.pwd)
  @node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarn bin`.chomp
  @webpack_config        = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
  @webpacker_config      = File.join(@app_path, "config/webpacker.yml")

  unless File.exist?(@webpack_config)
    $stderr.puts "webpack config #{@webpack_config} not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment."
    exit!
  end
end

Class Method Details

.run(argv) ⇒ Object



3
4
5
6
7
# File 'lib/webpacker/runner.rb', line 3

def self.run(argv)
  $stdout.sync = true

  new(argv).run
end