cssbundling-rails 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77c2a2dbfa75c9cdb60655f5624811509c3406c0628e3de359ebc8681c90a648
4
- data.tar.gz: 3cd9fa316f58f1ba5268561b8fe9bc5306393e3a10421283a984b98bdce56de5
3
+ metadata.gz: 1de04a37474ee74462c81c8c531c659bc5566aa8e19f4a7697e56d09f243c8c2
4
+ data.tar.gz: 9f958afff8e9068ad47291f2285eba9c28032785ff64a70ac66b11b8483cb3bc
5
5
  SHA512:
6
- metadata.gz: 1a5871258df72a6352adab32fa3440a8f935d16a19f58875a1c0394c9c3dfedb1e8dee93fc79183b8fbbab3bb388f8c7783a15c0c13786f5e33d810175e81036
7
- data.tar.gz: 372189f7681950572648f9f56aa578e47a6a42c1a7e12ac92d4f122fbd81433d493a09a05b22f2b0c47d7f9c122bafcce4ab41c57f34994be27534aee8e9f09c
6
+ metadata.gz: 54cd75ab9d1f2fa908fdeb14e9385ac77543af91d7757b0dc0b3ad4378e0b1764cfbf0b4d359a1eed5e8f28a9ae8b21619845dcaa28d7d6c6bd5341ea4534214
7
+ data.tar.gz: 55bb55f73f38a2ff2b39431ba20417797245cba519f3488861f90d5731ec7e6aeb71bd8b78040d5490ea2a177604fea5477d452e6b6dd364332dc4b8cb17e504
data/README.md CHANGED
@@ -43,6 +43,15 @@ Some CSS packages use new CSS features that are not supported by the default Sas
43
43
 
44
44
  A common issue is that your repository does not contain the output directory used by the build commands. You must have `app/assets/builds` available. Add the directory with a `.gitkeep` file, and you'll ensure it's available in production.
45
45
 
46
+ ### How do I avoid `ActionView::Template::Error: Error: Function rgb is missing argument $green`?
47
+
48
+ This might happen if your Gemfile.lock contains the legacy `sassc-rails`, which might be need while progressively migrating your project, or which might be a transitive dependency of a gem your project depends on and over which you have no control. In this case, prevent Sprockets from bundling the CSS on top of the bundling already performed by this gem. Make sure do this for all environments, not only production, otherwise your test suite may fail.
49
+
50
+ ```
51
+ # config/initializers/assets.rb
52
+ Rails.application.config.assets.css_compressor = nil
53
+ ```
54
+
46
55
  ### Why isn't Rails using my updated css files?
47
56
 
48
57
  Watch out - if you precompile your files locally, those will be served over the dynamically created ones you expect. The solution:
@@ -51,6 +60,15 @@ Watch out - if you precompile your files locally, those will be served over the
51
60
  rails assets:clobber
52
61
  ```
53
62
 
63
+ ### How do I include 3rd party stylesheets from `node_modules` in my bundle?
64
+
65
+ Use an `@import` statement and path to a specific stylesheet, omitting the `node_modules/` segment and the file's extension. For example:
66
+
67
+ ```scss
68
+ /* Desired file is at at node_modules/select2/dist/css/select2.css */
69
+ @import "select2/dist/css/select2";
70
+ ```
71
+
54
72
  ## License
55
73
 
56
74
  CSS Bundling for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module Cssbundling
2
- VERSION = "1.3.3"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require_relative "../helpers"
2
2
  self.extend Helpers
3
3
 
4
+ apply "#{__dir__}/../install.rb"
5
+
4
6
  say "Install Bootstrap with Bootstrap Icons, Popperjs/core and Autoprefixer"
5
7
  copy_file "#{__dir__}/application.bootstrap.scss",
6
8
  "app/assets/stylesheets/application.bootstrap.scss"
@@ -19,6 +21,19 @@ else
19
21
  say %(Add import * as bootstrap from "bootstrap" to your entry point JavaScript file), :red
20
22
  end
21
23
 
24
+ if Rails.root.join("config/importmap.rb").exist?
25
+ say "Pin Bootstrap"
26
+ append_to_file "config/importmap.rb", %(pin "bootstrap", to: "bootstrap.min.js"\n)
27
+
28
+ inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do
29
+ <<~RUBY
30
+ Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap/dist/js")
31
+ RUBY
32
+ end
33
+
34
+ append_to_file "config/initializers/assets.rb", %(Rails.application.config.assets.precompile << "bootstrap.min.js")
35
+ end
36
+
22
37
  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")
23
38
  add_package_json_script("build:css:prefix", "postcss ./app/assets/builds/application.css --use=autoprefixer --output=./app/assets/builds/application.css")
24
39
  add_package_json_script("build:css", "#{bundler_run_cmd} build:css:compile && #{bundler_run_cmd} build:css:prefix")
@@ -1,6 +1,8 @@
1
1
  require_relative "../helpers"
2
2
  self.extend Helpers
3
3
 
4
+ apply "#{__dir__}/../install.rb"
5
+
4
6
  say "Install Bulma"
5
7
  copy_file "#{__dir__}/application.bulma.scss",
6
8
  "app/assets/stylesheets/application.bulma.scss"
data/lib/install/dev CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
- if ! gem list foreman -i --silent; then
3
+ if gem list --no-installed --exact --silent foreman; then
4
4
  echo "Installing foreman..."
5
5
  gem install foreman
6
6
  fi
@@ -21,7 +21,7 @@ module Helpers
21
21
  if using_bun?
22
22
  package_json = JSON.parse(File.read("package.json"))
23
23
  package_json["scripts"] ||= {}
24
- package_json["scripts"][name] = script
24
+ package_json["scripts"][name] = script.gsub('\\"', '"')
25
25
  File.write("package.json", JSON.pretty_generate(package_json))
26
26
  run %(bun run #{name}) if run_script
27
27
  else
@@ -1,6 +1,8 @@
1
1
  require_relative "../helpers"
2
2
  self.extend Helpers
3
3
 
4
+ apply "#{__dir__}/../install.rb"
5
+
4
6
  say "Install PostCSS w/ nesting and autoprefixer"
5
7
  copy_file "#{__dir__}/postcss.config.js", "postcss.config.js"
6
8
  copy_file "#{__dir__}/application.postcss.css", "app/assets/stylesheets/application.postcss.css"
@@ -1,6 +1,8 @@
1
1
  require_relative "../helpers"
2
2
  self.extend Helpers
3
3
 
4
+ apply "#{__dir__}/../install.rb"
5
+
4
6
  say "Install Sass"
5
7
  copy_file "#{__dir__}/application.sass.scss", "app/assets/stylesheets/application.sass.scss"
6
8
  run "#{bundler_cmd} add sass"
@@ -1,6 +1,8 @@
1
1
  require_relative "../helpers"
2
2
  self.extend Helpers
3
3
 
4
+ apply "#{__dir__}/../install.rb"
5
+
4
6
  say "Install Tailwind (+PostCSS w/ autoprefixer)"
5
7
  copy_file "#{__dir__}/tailwind.config.js", "tailwind.config.js"
6
8
  copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/application.tailwind.css"
@@ -22,15 +22,36 @@ module Cssbundling
22
22
  extend self
23
23
 
24
24
  def install_command
25
- return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
26
- return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn')
27
- raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
25
+ case tool
26
+ when :bun then "bun install"
27
+ when :yarn then "yarn install"
28
+ when :pnpm then "pnpm install"
29
+ when :npm then "npm install"
30
+ else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
31
+ end
28
32
  end
29
33
 
30
34
  def build_command
31
- return "bun run build:css" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock'))
32
- return "yarn build:css" if File.exist?('yarn.lock') || tool_exists?('yarn')
33
- raise "cssbundling-rails: No suitable tool found for building CSS"
35
+ case tool
36
+ when :bun then "bun run build:css"
37
+ when :yarn then "yarn build:css"
38
+ when :pnpm then "pnpm build:css"
39
+ when :npm then "npm run build:css"
40
+ else raise "cssbundling-rails: No suitable tool found for building CSS"
41
+ end
42
+ end
43
+
44
+ def tool
45
+ case
46
+ when File.exist?('bun.lockb') then :bun
47
+ when File.exist?('yarn.lock') then :yarn
48
+ when File.exist?('pnpm-lock.yaml') then :pnpm
49
+ when File.exist?('package-lock.json') then :npm
50
+ when tool_exists?('bun') then :bun
51
+ when tool_exists?('yarn') then :yarn
52
+ when tool_exists?('pnpm') then :pnpm
53
+ when tool_exists?('npm') then :npm
54
+ end
34
55
  end
35
56
 
36
57
  def tool_exists?(tool)
@@ -1,32 +1,27 @@
1
1
  namespace :css do
2
2
  namespace :install do
3
- desc "Install shared elements for all bundlers"
4
- task :shared do
5
- system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install.rb", __dir__)}"
6
- end
7
-
8
3
  desc "Install Tailwind"
9
- task tailwind: "css:install:shared" do
4
+ task :tailwind do
10
5
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/tailwind/install.rb", __dir__)}"
11
6
  end
12
7
 
13
8
  desc "Install PostCSS"
14
- task postcss: "css:install:shared" do
9
+ task :postcss do
15
10
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/postcss/install.rb", __dir__)}"
16
11
  end
17
12
 
18
13
  desc "Install Sass"
19
- task sass: "css:install:shared" do
14
+ task :sass do
20
15
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/sass/install.rb", __dir__)}"
21
16
  end
22
17
 
23
18
  desc "Install Bootstrap"
24
- task bootstrap: "css:install:shared" do
19
+ task :bootstrap do
25
20
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bootstrap/install.rb", __dir__)}"
26
21
  end
27
22
 
28
23
  desc "Install Bulma"
29
- task bulma: "css:install:shared" do
24
+ task :bulma do
30
25
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bulma/install.rb", __dir__)}"
31
26
  end
32
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cssbundling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-18 00:00:00.000000000 Z
12
+ date: 2024-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.4.10
80
+ rubygems_version: 3.4.20
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via