cssbundling-rails 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/cssbundling/version.rb +1 -1
- data/lib/install/bootstrap/application.bootstrap.scss +1 -0
- data/lib/install/bootstrap/install.rb +9 -3
- data/lib/install/bulma/install.rb +1 -1
- data/lib/install/dev +1 -1
- data/lib/install/postcss/install.rb +1 -1
- data/lib/install/sass/install.rb +1 -1
- data/lib/install/tailwind/install.rb +2 -2
- data/lib/install/tailwind/tailwind.config.js +1 -0
- data/lib/tasks/cssbundling/build.rake +3 -1
- data/lib/tasks/cssbundling/clobber.rake +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63098c452d51cb9f77ad0729d5534865de3ea91d394086fdcdb63de5c6b75e71
|
4
|
+
data.tar.gz: f0d1b5c9f5fbfa97f5410d809df4726c034964ef174f17ab8d271879c6878a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf88ca29e427ad3de1f221631db1de73324ddae6dbe328a2e8b8c03c360affbe55880ac4b19f6a2a21ab25fa2e9ea39d80cbb3617f04feffe01a6a0fd466e8cb
|
7
|
+
data.tar.gz: f7d2c350f2fb440bcda25ae8b2d3aa835f28b6594938a4581cde0f9df79caf0f0892212ede68ecfcfcc7e8c8bf6b287c03689230c5df201308f34554ddc4f8bb
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ When you deploy your application to production, the `css:build` task attaches to
|
|
10
10
|
|
11
11
|
This also happens in testing where the bundler attaches to the `test:prepare` task to ensure the stylesheets have been bundled before testing commences. (Note that this currently only applies to rails `test:*` tasks (like `test:all` or `test:controllers`), not "rails test", as that doesn't load `test:prepare`).
|
12
12
|
|
13
|
-
If your test framework does not define a `test:prepare` Rake task, ensure that your test framework runs `css:build` to bundle stylesheets before testing commences.
|
13
|
+
If your test framework does not define a `test:prepare` Rake task, ensure that your test framework runs `css:build` to bundle stylesheets before testing commences. If your setup uses [jsbundling-rails](https://github.com/rails/jsbundling-rails) (ie, esbuild + tailwind), you will also need to run `javascript:build`.
|
14
14
|
|
15
15
|
That's it!
|
16
16
|
|
@@ -30,6 +30,10 @@ Or, in Rails 7+, you can preconfigure your new application to use a specific bun
|
|
30
30
|
|
31
31
|
## FAQ
|
32
32
|
|
33
|
+
### How does this compare to tailwindcss-rails and dartsass-rails?
|
34
|
+
|
35
|
+
If you're already relying on Node to process your JavaScript, this gem is the way to go. But if you're using [the default import map setup in Rails 7+](https://github.com/rails/importmap-rails/), you can avoid having to deal with Node at all by using the standalone versions of Tailwind CSS and Dart Sass that are available through [tailwindcss-rails](https://github.com/rails/tailwindcss-rails/) and [dartsass-rails](https://github.com/rails/dartsass-rails/). It's simpler, fewer moving parts, and still has all the functionality.
|
36
|
+
|
33
37
|
### How do I import relative CSS files with Tailwind?
|
34
38
|
|
35
39
|
If you want to use `@import` statements as part of your Tailwind application.js file, you need to [configure Tailwind to use `postcss` and then `postcss-import`](https://tailwindcss.com/docs/using-with-preprocessors#build-time-imports). But you should also consider simply referring to your other CSS files directly, instead of bundling them all into one big file. It's better for caching, and it's simpler to setup. You can refer to other CSS files by expanding the `stylesheet_link_tag` in `application.html.erb` like so: `<%= stylesheet_link_tag "application", "other", "styles", "data-turbo-track": "reload" %>`.
|
data/lib/cssbundling/version.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
say "Install Bootstrap with Popperjs/core"
|
1
|
+
say "Install Bootstrap with Bootstrap Icons and Popperjs/core"
|
2
2
|
copy_file "#{__dir__}/application.bootstrap.scss",
|
3
3
|
"app/assets/stylesheets/application.bootstrap.scss"
|
4
|
-
run "yarn add sass bootstrap @popperjs/core"
|
4
|
+
run "yarn add sass bootstrap bootstrap-icons @popperjs/core"
|
5
|
+
|
6
|
+
inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do
|
7
|
+
<<~RUBY
|
8
|
+
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font")
|
9
|
+
RUBY
|
10
|
+
end
|
5
11
|
|
6
12
|
if Rails.root.join("app/javascript/application.js").exist?
|
7
13
|
say "Appending Bootstrap JavaScript import to default entry point"
|
@@ -14,7 +20,7 @@ say "Add build:css script"
|
|
14
20
|
build_script = "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
|
15
21
|
|
16
22
|
if (`npx -v`.to_f < 7.1 rescue "Missing")
|
17
|
-
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :
|
23
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :red
|
18
24
|
else
|
19
25
|
run %(npm set-script build:css "#{build_script}")
|
20
26
|
run %(yarn build:css)
|
@@ -7,7 +7,7 @@ say "Add build:css script"
|
|
7
7
|
build_script = "sass ./app/assets/stylesheets/application.bulma.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
|
8
8
|
|
9
9
|
if (`npx -v`.to_f < 7.1 rescue "Missing")
|
10
|
-
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :
|
10
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :red
|
11
11
|
else
|
12
12
|
run %(npm set-script build:css "#{build_script}")
|
13
13
|
run %(yarn build:css)
|
data/lib/install/dev
CHANGED
@@ -7,7 +7,7 @@ say "Add build:css script"
|
|
7
7
|
build_script = "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css"
|
8
8
|
|
9
9
|
if (`npx -v`.to_f < 7.1 rescue "Missing")
|
10
|
-
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :
|
10
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :red
|
11
11
|
else
|
12
12
|
run %(npm set-script build:css "#{build_script}")
|
13
13
|
run %(yarn build:css)
|
data/lib/install/sass/install.rb
CHANGED
@@ -6,7 +6,7 @@ say "Add build:css script"
|
|
6
6
|
build_script = "sass ./app/assets/stylesheets/application.sass.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
|
7
7
|
|
8
8
|
if (`npx -v`.to_f < 7.1 rescue "Missing")
|
9
|
-
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :
|
9
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :red
|
10
10
|
else
|
11
11
|
run %(npm set-script build:css "#{build_script}")
|
12
12
|
run %(yarn build:css)
|
@@ -4,10 +4,10 @@ copy_file "#{__dir__}/application.tailwind.css", "app/assets/stylesheets/applica
|
|
4
4
|
run "yarn add tailwindcss@latest postcss@latest autoprefixer@latest"
|
5
5
|
|
6
6
|
say "Add build:css script"
|
7
|
-
build_script = "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css"
|
7
|
+
build_script = "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
|
8
8
|
|
9
9
|
if (`npx -v`.to_f < 7.1 rescue "Missing")
|
10
|
-
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :
|
10
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :red
|
11
11
|
else
|
12
12
|
run %(npm set-script build:css "#{build_script}")
|
13
13
|
run %(yarn build:css)
|
@@ -7,7 +7,9 @@ namespace :css do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
Rake::Task
|
10
|
+
if Rake::Task.task_defined?("assets:precompile")
|
11
|
+
Rake::Task["assets:precompile"].enhance(["css:build"])
|
12
|
+
end
|
11
13
|
|
12
14
|
if Rake::Task.task_defined?("test:prepare")
|
13
15
|
Rake::Task["test:prepare"].enhance(["css:build"])
|
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.1.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:
|
12
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|