Sha256: ed2de4486d456968dc7dcdaad45c9c3fa1ef51ab3860dfdcb6c9dfef5634fd6a

Contents?: true

Size: 985 Bytes

Versions: 14

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

module Boring
  module Jquery
    class InstallGenerator < Rails::Generators::Base
      desc "Adds JQuery to the application"

      def add_jquery_package
        say "Adding JQuery packages", :green
        run "yarn add jquery"
      end

      def add_jquery_plugin_provider_to_webpack_environment
        say "Initailizing tailwind configuration", :green
        if File.exist?("config/webpack/environment.js")
          insert_into_file "config/webpack/environment.js", <<~RUBY, after: /@rails\/webpacker.*\n/
            const webpack = require("webpack")

            environment.plugins.append("Provide", new webpack.ProvidePlugin({
              $: 'jquery',
              jQuery: 'jquery'
            }))
          RUBY
        else
          say <<~WARNING, :red
            ERROR: Looks like the webpacker installation is incomplete. Could not find environment.js in config/webpack.
          WARNING
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
boring_generators-0.15.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.14.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.13.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.12.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.11.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.10.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.9.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.8.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.7.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.6.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.5.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.4.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.3.0 lib/generators/boring/jquery/install/install_generator.rb
boring_generators-0.2.0 lib/generators/boring/jquery/install/install_generator.rb