Sha256: 197a1eb471a9f887f08b47abf11e6483395d3dca3e311f260f8b41dc09ed66c3

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'rails/generators/base'

module Tailwindcss
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("../../templates", __FILE__)

      def yarn_add_tailwindcss
        run "yarn --ignore-engines add tailwindcss@1.0.0 --tilde"
      end

      def init_tailwindcss
        run "./node_modules/.bin/tailwind init ./tailwind.config.js"
      end

      def setup_tailwindcss
        template "tailwind.css", "app/javascript/css/application.css"
        append_to_file "app/javascript/packs/application.js", 'import "../css/application.css"'
      end

      def configure_postcssrc
        inject_into_file "postcss.config.js", "    require('tailwindcss'),\n", after: "require('postcss-import'),\n"
        inject_into_file "postcss.config.js", "    require('autoprefixer'),\n", after: "plugins: [\n"
      end

      def remove_corejs_3
        gsub_file "babel.config.js", /regenerator: true,\n          corejs: 3/, "regenerator: true,"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tailwindcss-1.0.3 lib/generators/tailwindcss/install_generator.rb
tailwindcss-1.0.2 lib/generators/tailwindcss/install_generator.rb
tailwindcss-1.0.1 lib/generators/tailwindcss/install_generator.rb
tailwindcss-1.0.0 lib/generators/tailwindcss/install_generator.rb