cssbundling-rails 1.3.3 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/cssbundling/version.rb +1 -1
- data/lib/install/bootstrap/install.rb +15 -0
- data/lib/install/bulma/install.rb +2 -0
- data/lib/install/dev +2 -2
- data/lib/install/helpers.rb +1 -1
- data/lib/install/install.rb +1 -1
- data/lib/install/postcss/install.rb +2 -0
- data/lib/install/sass/install.rb +2 -0
- data/lib/install/tailwind/install.rb +2 -0
- data/lib/tasks/cssbundling/build.rake +27 -6
- data/lib/tasks/cssbundling/install.rake +5 -10
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a644c7ba1cafbe1174c0c1fec2cbc9b545e1fc9e620d9c9e348c9cd58f2477a9
|
4
|
+
data.tar.gz: 756402251b7446a021598edcbd26b24fd6e89be36aeeb0f42592febabe5d336a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63e4c7932449cf676e20d0f3d6510c653ecf1e90aa1fdabae9a5f43b4edb41ee6e8697ce12cff1b1debd2a0d410356ffeec141fe1032b2015edb689e1c6a8920
|
7
|
+
data.tar.gz: b0abcc8f73a13d588066195646989b2218c5a7bd3d9d85344ae1802136ddfa3f660eca75af03835f5af4f75f0c9ea87d026dbbd99efbc4a1b12104d374d6689a
|
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).
|
data/lib/cssbundling/version.rb
CHANGED
@@ -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")
|
data/lib/install/dev
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env sh
|
2
2
|
|
3
|
-
if
|
3
|
+
if gem list --no-installed --exact --silent foreman; then
|
4
4
|
echo "Installing foreman..."
|
5
5
|
gem install foreman
|
6
6
|
fi
|
@@ -8,4 +8,4 @@ fi
|
|
8
8
|
# Default to port 3000 if not specified
|
9
9
|
export PORT="${PORT:-3000}"
|
10
10
|
|
11
|
-
exec foreman start -f Procfile.dev "$@"
|
11
|
+
exec foreman start -f Procfile.dev --env /dev/null "$@"
|
data/lib/install/helpers.rb
CHANGED
@@ -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
|
data/lib/install/install.rb
CHANGED
@@ -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"
|
data/lib/install/sass/install.rb
CHANGED
@@ -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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
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
|
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
|
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
|
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
|
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.
|
4
|
+
version: 1.4.1
|
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:
|
12
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -61,7 +61,8 @@ files:
|
|
61
61
|
homepage: https://github.com/rails/cssbundling-rails
|
62
62
|
licenses:
|
63
63
|
- MIT
|
64
|
-
metadata:
|
64
|
+
metadata:
|
65
|
+
changelog_uri: https://github.com/rails/cssbundling-rails/releases
|
65
66
|
post_install_message:
|
66
67
|
rdoc_options: []
|
67
68
|
require_paths:
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.5.11
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via
|