Sha256: b3702a9c53fee3d66468f8ea4057c9b551232cd472ae58dcb0e596a69f817c17

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

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"
      end

      def create_javascript_css_directory
        run "mkdir app/javascript/css"
      end

      def init_tailwindcss
        run "./node_modules/.bin/tailwind init app/javascript/css/tailwind.js"
      end

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

      def configure_postcssrc
        inject_into_file "./.postcssrc.yml", "\n  tailwindcss: './app/javascript/css/tailwind.js'", before: "postcss-cssnext: {}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tailwindcss-0.2.0 lib/generators/tailwindcss/install_generator.rb