Sha256: 3161388c47cd39fb493fd63689969251e71c0669c843c81a6419f7649a84d71b

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

require "rails/railtie"

module Webpacker
  module PNPM
    class Railtie < Rails::Railtie
      rake_tasks do
        # load all the rake tasks within the `tasks` directory
        Dir[File.join(File.dirname(__FILE__), "../tasks/**/*.rake")].each do |task|
          load task
        end
      end

      # manually specify node_modules bin path to skip Yarn execution during
      # Webpack runner initialization
      config.before_configuration do
        begin
          ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.join(`pnpm root`.chomp, ".bin")
        rescue Errno::ENOENT
          # use abort instead of Rails' logger because it doesn't show up when
          # run within Rake tasks
          abort(
            <<~HEREDOC.squish
              \e[31m[FATAL] pnpm is not installed or not present in $PATH.
              Install pnpm and try again.\e[0m
            HEREDOC
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webpacker-pnpm-1.2.1 lib/webpacker/pnpm/railtie.rb