Sha256: b5b8f67d89d38e9ba93d6f9674eb45ed135cd2de5dd3cd5805eb01b573baf042

Contents?: true

Size: 853 Bytes

Versions: 5

Compression:

Stored size: 853 Bytes

Contents

require "shellwords"
require "webpacker/runner"

module Webpacker
  class WebpackRunner < Webpacker::Runner
    def run
      env = Webpacker::Compiler.env
      env["WEBPACKER_CONFIG"] = @webpacker_config

      cmd = if node_modules_bin_exist?
        ["#{@node_modules_bin_path}/webpack"]
      else
        ["yarn", "webpack"]
      end

      if @argv.include?("--debug-webpacker")
        cmd = [ "node", "--inspect-brk"] + cmd
      end

      if @argv.include?("--trace-deprecation")
        cmd = [ "node", "--trace-deprecation"] + cmd
        @argv.delete "--trace-deprecation"
      end

      cmd += ["--config", @webpack_config] + @argv

      Dir.chdir(@app_path) do
        Kernel.exec env, *cmd
      end
    end

    private
      def node_modules_bin_exist?
        File.exist?("#{@node_modules_bin_path}/webpack")
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
webpacker-6.0.0.beta.2 lib/webpacker/webpack_runner.rb
webpacker-6.0.0.beta.1 lib/webpacker/webpack_runner.rb
webpacker-6.0.0.beta lib/webpacker/webpack_runner.rb
webpacker-6.0.0.pre.2 lib/webpacker/webpack_runner.rb
webpacker-6.0.0.pre.1 lib/webpacker/webpack_runner.rb