cssbundling-rails-1.4.1/ 0000755 0000041 0000041 00000000000 14665270341 015200 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/ 0000755 0000041 0000041 00000000000 14665270341 015746 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/tasks/ 0000755 0000041 0000041 00000000000 14665270341 017073 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/tasks/cssbundling/ 0000755 0000041 0000041 00000000000 14665270341 021406 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/tasks/cssbundling/install.rake 0000644 0000041 0000041 00000001736 14665270341 023727 0 ustar www-data www-data namespace :css do namespace :install do desc "Install Tailwind" task :tailwind do system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/tailwind/install.rb", __dir__)}" end desc "Install PostCSS" task :postcss do system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/postcss/install.rb", __dir__)}" end desc "Install Sass" task :sass do system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/sass/install.rb", __dir__)}" end desc "Install Bootstrap" task :bootstrap do system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bootstrap/install.rb", __dir__)}" end desc "Install Bulma" task :bulma do system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bulma/install.rb", __dir__)}" end end end cssbundling-rails-1.4.1/lib/tasks/cssbundling/build.rake 0000644 0000041 0000041 00000004265 14665270341 023360 0 ustar www-data www-data namespace :css do desc "Install JavaScript dependencies" task :install do command = Cssbundling::Tasks.install_command unless system(command) raise "cssbundling-rails: Command install failed, ensure #{command.split.first} is installed" end end desc "Build your CSS bundle" build_task = task :build do command = Cssbundling::Tasks.build_command unless system(command) raise "cssbundling-rails: Command build failed, ensure `#{command}` runs without errors" end end build_task.prereqs << :install unless ENV["SKIP_YARN_INSTALL"] || ENV["SKIP_BUN_INSTALL"] end module Cssbundling module Tasks extend self def install_command case tool when :bun then "bun install" when :yarn then "yarn install" when :pnpm then "pnpm install" when :npm then "npm install" else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies" end end def build_command case tool when :bun then "bun run build:css" when :yarn then "yarn build:css" when :pnpm then "pnpm build:css" when :npm then "npm run build:css" else raise "cssbundling-rails: No suitable tool found for building CSS" end end def tool case when File.exist?('bun.lockb') then :bun when File.exist?('yarn.lock') then :yarn when File.exist?('pnpm-lock.yaml') then :pnpm when File.exist?('package-lock.json') then :npm when tool_exists?('bun') then :bun when tool_exists?('yarn') then :yarn when tool_exists?('pnpm') then :pnpm when tool_exists?('npm') then :npm end end def tool_exists?(tool) system "command -v #{tool} > /dev/null" end end end unless ENV["SKIP_CSS_BUILD"] if Rake::Task.task_defined?("assets:precompile") Rake::Task["assets:precompile"].enhance(["css:build"]) end if Rake::Task.task_defined?("test:prepare") Rake::Task["test:prepare"].enhance(["css:build"]) elsif Rake::Task.task_defined?("spec:prepare") Rake::Task["spec:prepare"].enhance(["css:build"]) elsif Rake::Task.task_defined?("db:test:prepare") Rake::Task["db:test:prepare"].enhance(["css:build"]) end end cssbundling-rails-1.4.1/lib/tasks/cssbundling/clobber.rake 0000644 0000041 0000041 00000000377 14665270341 023671 0 ustar www-data www-data namespace :css do desc "Remove CSS builds" task :clobber do rm_rf Dir["app/assets/builds/**/[^.]*.{css,css.map}"], verbose: false end end if Rake::Task.task_defined?("assets:clobber") Rake::Task["assets:clobber"].enhance(["css:clobber"]) end cssbundling-rails-1.4.1/lib/install/ 0000755 0000041 0000041 00000000000 14665270341 017414 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/sass/ 0000755 0000041 0000041 00000000000 14665270341 020365 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/sass/application.sass.scss 0000644 0000041 0000041 00000000043 14665270341 024532 0 ustar www-data www-data // Entry point for your Sass build cssbundling-rails-1.4.1/lib/install/sass/install.rb 0000644 0000041 0000041 00000000651 14665270341 022362 0 ustar www-data www-data require_relative "../helpers" self.extend Helpers apply "#{__dir__}/../install.rb" say "Install Sass" copy_file "#{__dir__}/application.sass.scss", "app/assets/stylesheets/application.sass.scss" run "#{bundler_cmd} add sass" say "Add build:css script" add_package_json_script "build:css", "sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules" cssbundling-rails-1.4.1/lib/install/helpers.rb 0000644 0000041 0000041 00000002163 14665270341 021405 0 ustar www-data www-data require 'json' module Helpers def bundler_cmd using_bun? ? "bun" : "yarn" end def bundler_run_cmd using_bun? ? "bun run" : "yarn" end def using_bun? File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) end def tool_exists?(tool) system "command -v #{tool} > /dev/null" end def add_package_json_script(name, script, run_script=true) if using_bun? package_json = JSON.parse(File.read("package.json")) package_json["scripts"] ||= {} package_json["scripts"][name] = script.gsub('\\"', '"') File.write("package.json", JSON.pretty_generate(package_json)) run %(bun run #{name}) if run_script else case `npx -v`.to_f when 7.1...8.0 say "Add #{name} script" run %(npm set-script #{name} "#{script}") run %(yarn #{name}) if run_script when (8.0..) say "Add #{name} script" run %(npm pkg set scripts.#{name}="#{script}") run %(yarn #{name}) if run_script else say %(Add "scripts": { "#{name}": "#{script}" } to your package.json), :green end end end end cssbundling-rails-1.4.1/lib/install/bootstrap/ 0000755 0000041 0000041 00000000000 14665270341 021431 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/bootstrap/application.bootstrap.scss 0000644 0000041 0000041 00000000124 14665270341 026642 0 ustar www-data www-data @import 'bootstrap/scss/bootstrap'; @import 'bootstrap-icons/font/bootstrap-icons'; cssbundling-rails-1.4.1/lib/install/bootstrap/install.rb 0000644 0000041 0000041 00000004374 14665270341 023434 0 ustar www-data www-data require_relative "../helpers" self.extend Helpers apply "#{__dir__}/../install.rb" say "Install Bootstrap with Bootstrap Icons, Popperjs/core and Autoprefixer" copy_file "#{__dir__}/application.bootstrap.scss", "app/assets/stylesheets/application.bootstrap.scss" run "#{bundler_cmd} add sass bootstrap bootstrap-icons @popperjs/core postcss postcss-cli autoprefixer nodemon" inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do <<~RUBY Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font") RUBY end if Rails.root.join("app/javascript/application.js").exist? say "Appending Bootstrap JavaScript import to default entry point" append_to_file "app/javascript/application.js", %(import * as bootstrap from "bootstrap"\n) else say %(Add import * as bootstrap from "bootstrap" to your entry point JavaScript file), :red end if Rails.root.join("config/importmap.rb").exist? say "Pin Bootstrap" append_to_file "config/importmap.rb", %(pin "bootstrap", to: "bootstrap.min.js"\n) inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do <<~RUBY Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap/dist/js") RUBY end append_to_file "config/initializers/assets.rb", %(Rails.application.config.assets.precompile << "bootstrap.min.js") end add_package_json_script("build:css:compile", "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules") add_package_json_script("build:css:prefix", "postcss ./app/assets/builds/application.css --use=autoprefixer --output=./app/assets/builds/application.css") add_package_json_script("build:css", "#{bundler_run_cmd} build:css:compile && #{bundler_run_cmd} build:css:prefix") add_package_json_script("watch:css", "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \\\"#{bundler_run_cmd} build:css\\\"", false) gsub_file "Procfile.dev", "build:css --watch", "watch:css" package_json = JSON.parse(File.read("package.json")) package_json["browserslist"] ||= {} package_json["browserslist"] = ["defaults"] File.write("package.json", JSON.pretty_generate(package_json)) cssbundling-rails-1.4.1/lib/install/Procfile_for_node.dev 0000644 0000041 0000041 00000000113 14665270341 023525 0 ustar www-data www-data web: env RUBY_DEBUG_OPEN=true bin/rails server css: yarn build:css --watch cssbundling-rails-1.4.1/lib/install/postcss/ 0000755 0000041 0000041 00000000000 14665270341 021112 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/postcss/postcss.config.js 0000644 0000041 0000041 00000000203 14665270341 024405 0 ustar www-data www-data module.exports = { plugins: [ require('postcss-import'), require('postcss-nesting'), require('autoprefixer'), ], } cssbundling-rails-1.4.1/lib/install/postcss/application.postcss.css 0000644 0000041 0000041 00000000051 14665270341 025620 0 ustar www-data www-data /* Entry point for your PostCSS build */ cssbundling-rails-1.4.1/lib/install/postcss/install.rb 0000644 0000041 0000041 00000001044 14665270341 023104 0 ustar www-data www-data require_relative "../helpers" self.extend Helpers apply "#{__dir__}/../install.rb" say "Install PostCSS w/ nesting and autoprefixer" copy_file "#{__dir__}/postcss.config.js", "postcss.config.js" copy_file "#{__dir__}/application.postcss.css", "app/assets/stylesheets/application.postcss.css" run "#{bundler_cmd} add postcss postcss-cli postcss-import postcss-nesting autoprefixer" say "Add build:css script" add_package_json_script "build:css", "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css" cssbundling-rails-1.4.1/lib/install/bulma/ 0000755 0000041 0000041 00000000000 14665270341 020514 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/bulma/install.rb 0000644 0000041 0000041 00000000666 14665270341 022517 0 ustar www-data www-data require_relative "../helpers" self.extend Helpers apply "#{__dir__}/../install.rb" say "Install Bulma" copy_file "#{__dir__}/application.bulma.scss", "app/assets/stylesheets/application.bulma.scss" run "#{bundler_cmd} add sass bulma" say "Add build:css script" add_package_json_script "build:css", "sass ./app/assets/stylesheets/application.bulma.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules" cssbundling-rails-1.4.1/lib/install/bulma/application.bulma.scss 0000644 0000041 0000041 00000002162 14665270341 025014 0 ustar www-data www-data // @charset "utf-8"; // Import a Google Font // @import url('https://fonts.googleapis.com/css?family=Nunito:400,700'); // Set your brand colors // $purple: #8A4D76; // $pink: #FA7C91; // $brown: #757763; // $beige-light: #D0D1CD; // $beige-lighter: #EFF0EB; // Update Bulma's global variables // $family-sans-serif: "Nunito", sans-serif; // $grey-dark: $brown; // $grey-light: $beige-light; // $primary: $purple; // $link: $pink; // $widescreen-enabled: false; // $fullhd-enabled: false; // Update some of Bulma's component variables // $body-background-color: $beige-lighter; // $control-border-width: 2px; // $input-border-color: transparent; // $input-shadow: none; // Import only what you need from Bulma // @import "bulma/sass/utilities/_all.sass"; // @import "bulma/sass/base/_all.sass"; // @import "bulma/sass/elements/button.sass"; // @import "bulma/sass/elements/container.sass"; // @import "bulma/sass/elements/title.sass"; // @import "bulma/sass/form/_all.sass"; // @import "bulma/sass/components/navbar.sass"; // @import "bulma/sass/layout/hero.sass"; // @import "bulma/sass/layout/section.sass"; @import 'bulma/bulma'; cssbundling-rails-1.4.1/lib/install/install.rb 0000644 0000041 0000041 00000004067 14665270341 021416 0 ustar www-data www-data require_relative "helpers" self.extend Helpers say "Build into app/assets/builds" empty_directory "app/assets/builds" keep_file "app/assets/builds" if (sprockets_manifest_path = Rails.root.join("app/assets/config/manifest.js")).exist? append_to_file sprockets_manifest_path, %(//= link_tree ../builds\n) say "Stop linking stylesheets automatically" gsub_file "app/assets/config/manifest.js", "//= link_directory ../stylesheets .css\n", "" end if Rails.root.join(".gitignore").exist? append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n)) append_to_file(".gitignore", %(\n/node_modules\n)) end say "Remove app/assets/stylesheets/application.css so build output can take over" remove_file "app/assets/stylesheets/application.css" if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist? say "Add stylesheet link tag in application layout" insert_into_file( app_layout_path.to_s, defined?(Turbo) ? %(\n <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>) : %(\n <%= stylesheet_link_tag "application" %>), before: /\s*<\/head>/ ) else say "Default application.html.erb is missing!", :red if defined?(Turbo) say %( Add <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> within the
tag in your custom layout.) else say %( Add <%= stylesheet_link_tag "application" %> within the tag in your custom layout.) end end unless Rails.root.join("package.json").exist? say "Add default package.json" copy_file "#{__dir__}/package.json", "package.json" end if Rails.root.join("Procfile.dev").exist? append_to_file "Procfile.dev", "css: #{bundler_run_cmd} build:css --watch\n" else say "Add default Procfile.dev" copy_file "#{__dir__}/#{using_bun? ? "Procfile_for_bun.dev" : "Procfile_for_node.dev"}", "Procfile.dev" say "Ensure foreman is installed" run "gem install foreman" end say "Add bin/dev to start foreman" copy_file "#{__dir__}/dev", "bin/dev", force: true chmod "bin/dev", 0755, verbose: false cssbundling-rails-1.4.1/lib/install/dev 0000755 0000041 0000041 00000000403 14665270341 020115 0 ustar www-data www-data #!/usr/bin/env sh if gem list --no-installed --exact --silent foreman; then echo "Installing foreman..." gem install foreman fi # Default to port 3000 if not specified export PORT="${PORT:-3000}" exec foreman start -f Procfile.dev --env /dev/null "$@" cssbundling-rails-1.4.1/lib/install/tailwind/ 0000755 0000041 0000041 00000000000 14665270341 021227 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/install/tailwind/application.tailwind.css 0000644 0000041 0000041 00000000073 14665270341 026056 0 ustar www-data www-data @tailwind base; @tailwind components; @tailwind utilities; cssbundling-rails-1.4.1/lib/install/tailwind/install.rb 0000644 0000041 0000041 00000001057 14665270341 023225 0 ustar www-data www-data require_relative "../helpers" self.extend Helpers apply "#{__dir__}/../install.rb" say "Install Tailwind (+PostCSS w/ autoprefixer)" copy_file "#{__dir__}/tailwind.config.js", "tailwind.config.js" copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css" run "#{bundler_cmd} add tailwindcss@latest postcss@latest autoprefixer@latest" say "Add build:css script" add_package_json_script "build:css", "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify" cssbundling-rails-1.4.1/lib/install/tailwind/tailwind.config.js 0000644 0000041 0000041 00000000254 14665270341 024645 0 ustar www-data www-data module.exports = { content: [ './app/views/**/*.html.erb', './app/helpers/**/*.rb', './app/assets/stylesheets/**/*.css', './app/javascript/**/*.js' ] } cssbundling-rails-1.4.1/lib/install/tailwind/package.json 0000644 0000041 0000041 00000000270 14665270341 023514 0 ustar www-data www-data { "name": "app", "private": "true", "scripts": { "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css" } } cssbundling-rails-1.4.1/lib/install/Procfile_for_bun.dev 0000644 0000041 0000041 00000000116 14665270341 023367 0 ustar www-data www-data web: env RUBY_DEBUG_OPEN=true bin/rails server css: bun run build:css --watch cssbundling-rails-1.4.1/lib/install/package.json 0000644 0000041 0000041 00000000051 14665270341 021676 0 ustar www-data www-data { "name": "app", "private": "true" } cssbundling-rails-1.4.1/lib/cssbundling/ 0000755 0000041 0000041 00000000000 14665270341 020261 5 ustar www-data www-data cssbundling-rails-1.4.1/lib/cssbundling/engine.rb 0000755 0000041 0000041 00000000076 14665270341 022061 0 ustar www-data www-data module Cssbundling class Engine < ::Rails::Engine end end cssbundling-rails-1.4.1/lib/cssbundling/version.rb 0000644 0000041 0000041 00000000053 14665270341 022271 0 ustar www-data www-data module Cssbundling VERSION = "1.4.1" end cssbundling-rails-1.4.1/lib/cssbundling-rails.rb 0000644 0000041 0000041 00000000123 14665270341 021712 0 ustar www-data www-data module Cssbundling end require "cssbundling/version" require "cssbundling/engine" cssbundling-rails-1.4.1/MIT-LICENSE 0000644 0000041 0000041 00000002054 14665270341 016635 0 ustar www-data www-data Copyright (c) 2021 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cssbundling-rails-1.4.1/cssbundling-rails.gemspec 0000644 0000041 0000041 00000004516 14665270341 022176 0 ustar www-data www-data ######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: cssbundling-rails 1.4.1 ruby lib Gem::Specification.new do |s| s.name = "cssbundling-rails".freeze s.version = "1.4.1" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.metadata = { "changelog_uri" => "https://github.com/rails/cssbundling-rails/releases" } if s.respond_to? :metadata= s.require_paths = ["lib".freeze] s.authors = ["David Heinemeier Hansson".freeze, "Dom Christie".freeze] s.date = "2024-07-29" s.email = "david@loudthinking.com".freeze s.files = ["MIT-LICENSE".freeze, "README.md".freeze, "lib/cssbundling-rails.rb".freeze, "lib/cssbundling/engine.rb".freeze, "lib/cssbundling/version.rb".freeze, "lib/install/Procfile_for_bun.dev".freeze, "lib/install/Procfile_for_node.dev".freeze, "lib/install/bootstrap/application.bootstrap.scss".freeze, "lib/install/bootstrap/install.rb".freeze, "lib/install/bulma/application.bulma.scss".freeze, "lib/install/bulma/install.rb".freeze, "lib/install/dev".freeze, "lib/install/helpers.rb".freeze, "lib/install/install.rb".freeze, "lib/install/package.json".freeze, "lib/install/postcss/application.postcss.css".freeze, "lib/install/postcss/install.rb".freeze, "lib/install/postcss/postcss.config.js".freeze, "lib/install/sass/application.sass.scss".freeze, "lib/install/sass/install.rb".freeze, "lib/install/tailwind/application.tailwind.css".freeze, "lib/install/tailwind/install.rb".freeze, "lib/install/tailwind/package.json".freeze, "lib/install/tailwind/tailwind.config.js".freeze, "lib/tasks/cssbundling/build.rake".freeze, "lib/tasks/cssbundling/clobber.rake".freeze, "lib/tasks/cssbundling/install.rake".freeze] s.homepage = "https://github.com/rails/cssbundling-rails".freeze s.licenses = ["MIT".freeze] s.rubygems_version = "3.3.15".freeze s.summary = "Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via Node.js.".freeze if s.respond_to? :specification_version then s.specification_version = 4 end if s.respond_to? :add_runtime_dependency then s.add_runtime_dependency(%q