cssbundling-rails 0.2.8 → 1.1.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 +11 -4
- data/lib/cssbundling/version.rb +1 -1
- data/lib/install/bootstrap/application.bootstrap.scss +1 -0
- data/lib/install/bootstrap/install.rb +10 -4
- data/lib/install/bulma/install.rb +2 -2
- data/lib/install/dev +2 -2
- data/lib/install/postcss/install.rb +1 -1
- data/lib/install/sass/install.rb +2 -2
- 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 +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99329a3089f29c127a662c2b9ee910f0d432a450dc8f8581a97e0876cbbafdff
|
4
|
+
data.tar.gz: d5bc8749354e3094058d2cb0c8151200f15b7a455e2913ed43f1202e1fb40771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d66dcdf7c882660552852c38b6bb5066d9b53844ae68c7d937a0886cdfe7e29a70360d68d57ead20f21b4bbf6c0f92a09386c98259e901ceb300f5ac47706c0a
|
7
|
+
data.tar.gz: 7f025dd959ffc7a8453198c4537e795d82f933f74c9ed0cdb82bd44b1a3efba22e7ebd8701ce163c1d6501cef231899e484a0cdd64a40de059da47ee82480278
|
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
|
|
@@ -21,15 +21,18 @@ You can configure your bundler options in the `build:css` script in `package.jso
|
|
21
21
|
|
22
22
|
You must already have node and yarn installed on your system. You will also need npx version 7.1.0 or later. Then:
|
23
23
|
|
24
|
-
1.
|
25
|
-
2. Run `./bin/
|
26
|
-
3. Run `./bin/rails css:install:[tailwind|bootstrap|bulma|postcss|sass]`
|
24
|
+
1. Run `./bin/bundle add cssbundling-rails`
|
25
|
+
2. Run `./bin/rails css:install:[tailwind|bootstrap|bulma|postcss|sass]`
|
27
26
|
|
28
27
|
Or, in Rails 7+, you can preconfigure your new application to use a specific bundler with `rails new myapp --css [tailwind|bootstrap|bulma|postcss|sass]`.
|
29
28
|
|
30
29
|
|
31
30
|
## FAQ
|
32
31
|
|
32
|
+
### How does this compare to tailwindcss-rails and dartsass-rails?
|
33
|
+
|
34
|
+
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.
|
35
|
+
|
33
36
|
### How do I import relative CSS files with Tailwind?
|
34
37
|
|
35
38
|
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" %>`.
|
@@ -38,6 +41,10 @@ If you want to use `@import` statements as part of your Tailwind application.js
|
|
38
41
|
|
39
42
|
Some CSS packages use new CSS features that are not supported by the default SassC rails integration that previous versions of Rails used. If you hit such an incompatibility, it'll likely be in the form of a `SassC::SyntaxError` when running `assets:precompile`. The fix is to `bundle remove sass-rails` (or `sassc-rails`, if you were using that).
|
40
43
|
|
44
|
+
### Why do I get `application.css not in asset pipeline` in production?
|
45
|
+
|
46
|
+
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.
|
47
|
+
|
41
48
|
## License
|
42
49
|
|
43
50
|
CSS Bundling for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
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"
|
@@ -11,10 +17,10 @@ else
|
|
11
17
|
end
|
12
18
|
|
13
19
|
say "Add build:css script"
|
14
|
-
build_script = "sass ./app/assets/stylesheets/application.bootstrap.scss
|
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)
|
@@ -4,10 +4,10 @@ copy_file "#{__dir__}/application.bulma.scss",
|
|
4
4
|
run "yarn add sass bulma"
|
5
5
|
|
6
6
|
say "Add build:css script"
|
7
|
-
build_script = "sass ./app/assets/stylesheets/application.bulma.scss
|
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
@@ -3,10 +3,10 @@ copy_file "#{__dir__}/application.sass.scss", "app/assets/stylesheets/applicatio
|
|
3
3
|
run "yarn add sass"
|
4
4
|
|
5
5
|
say "Add build:css script"
|
6
|
-
build_script = "sass ./app/assets/stylesheets/application.sass.scss
|
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,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cssbundling-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
- Dom Christie
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 6.0.0
|
28
|
-
description:
|
28
|
+
description:
|
29
29
|
email: david@loudthinking.com
|
30
30
|
executables: []
|
31
31
|
extensions: []
|
@@ -60,7 +60,7 @@ homepage: https://github.com/rails/cssbundling-rails
|
|
60
60
|
licenses:
|
61
61
|
- MIT
|
62
62
|
metadata: {}
|
63
|
-
post_install_message:
|
63
|
+
post_install_message:
|
64
64
|
rdoc_options: []
|
65
65
|
require_paths:
|
66
66
|
- lib
|
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
78
|
+
rubygems_version: 3.3.14
|
79
|
+
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via
|
82
82
|
Node.js.
|