Sha256: be2fb4ed79dacde105a1016fb9be19c315cbf939779ef6e3364fc2c087b817fe
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true require_relative "../../lib/plutonium_generators" module Pu module Core class AssetsGenerator < Rails::Generators::Base include PlutoniumGenerators::Generator source_root File.expand_path("templates", __dir__) desc "Setup plutonium assets" def start install_dependencies copy_tailwind_config configure_application replace_build_script import_styles rescue => e exception "#{self.class} failed:", e end private def copy_tailwind_config copy_file "tailwind.config.js", force: true copy_file "postcss.config.js", force: true end def install_dependencies run "yarn add @radioactive-labs/plutonium flowbite @tailwindcss/forms @tailwindcss/typography flowbite-typography postcss-cli cssnano marked" end def configure_application insert_into_file "app/javascript/controllers/index.js", <<~EOT import { registerControllers } from "@radioactive-labs/plutonium" registerControllers(application) EOT configure_plutonium "config.assets.stylesheet = \"application\"" configure_plutonium "config.assets.script = \"application\"" end def replace_build_script gsub_file "package.json", /"build:css":.*/, '"build:css": "postcss ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css"' end def import_styles prepend_to_file "app/assets/stylesheets/application.tailwind.css", "@import \"gem:plutonium/src/css/plutonium.css\";\n\n" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plutonium-0.16.3 | lib/generators/pu/core/assets/assets_generator.rb |