Sha256: 522c54a34c34052e1c284adacb9697665fd2ee6bc7b5d6dce0d1acd251455b23

Contents?: true

Size: 802 Bytes

Versions: 7

Compression:

Stored size: 802 Bytes

Contents

module ActiveadminAddons
  module Generators
    class WebpackerGenerator < Rails::Generators::Base
      def add_javascripts
        file_path = 'app/javascript/packs/active_admin.js'
        reference = "import \"@activeadmin/activeadmin\";\n"

        inject_into_file(file_path, js_assets, after: reference)
      end

      def add_stylesheets
        file_path = 'app/javascript/stylesheets/active_admin.scss'

        begin
          prepend_file(file_path, css_assets)
        end
      end

      def install_package
        run "yarn add activeadmin_addons"
      end

      private

      def js_assets
        to_add = "import \"activeadmin_addons\"\n"
        to_add
      end

      def css_assets
        "@import 'activeadmin_addons/src/stylesheets/all';\n"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeadmin_addons-1.10.2 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons-1.10.1 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons-1.10.0 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons-1.9.0 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons-1.8.3 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons-1.8.2 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb
activeadmin_addons_rails6-1.7.2 lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb