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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6f21b9a86c12228d96ebd215a160027dd21f357d10f89c02fefe843259e3e45
4
- data.tar.gz: 73184cd1d42cb4c61d8c0383110b5c4681227634f35c6e22f552864ffe07aa49
3
+ metadata.gz: 99329a3089f29c127a662c2b9ee910f0d432a450dc8f8581a97e0876cbbafdff
4
+ data.tar.gz: d5bc8749354e3094058d2cb0c8151200f15b7a455e2913ed43f1202e1fb40771
5
5
  SHA512:
6
- metadata.gz: a3a6f1ca987b13359faf3d7d10d2f52a4e0c86aba32818ee0c89551df6b08b4907db3df5b673ff27ee980c8dea373b58e86fcb6d054e49f68248ff047d5240aa
7
- data.tar.gz: bf50b191467c6f59621c4979a016af67e5dd6bb6f6931b80778440d2d985bf0ac65b52571a4e64e6483b5572048042520875dbd248acb348073fcbe8a893ec88
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. Add `cssbundling-rails` to your Gemfile with `gem 'cssbundling-rails'`
25
- 2. Run `./bin/bundle install`
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).
@@ -1,3 +1,3 @@
1
1
  module Cssbundling
2
- VERSION = "0.2.8"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -1 +1,2 @@
1
1
  @import 'bootstrap/scss/bootstrap';
2
+ @import 'bootstrap-icons/font/bootstrap-icons';
@@ -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 ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
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), :green
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 ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
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), :green
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
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- if ! command -v foreman &> /dev/null
3
+ if ! foreman version &> /dev/null
4
4
  then
5
5
  echo "Installing foreman..."
6
6
  gem install foreman
7
7
  fi
8
8
 
9
- foreman start -f Procfile.dev
9
+ foreman start -f Procfile.dev "$@"
@@ -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), :green
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)
@@ -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 ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
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), :green
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), :green
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)
@@ -2,6 +2,7 @@ module.exports = {
2
2
  content: [
3
3
  './app/views/**/*.html.erb',
4
4
  './app/helpers/**/*.rb',
5
+ './app/assets/stylesheets/**/*.css',
5
6
  './app/javascript/**/*.js'
6
7
  ]
7
8
  }
@@ -7,7 +7,9 @@ namespace :css do
7
7
  end
8
8
  end
9
9
 
10
- Rake::Task["assets:precompile"].enhance(["css:build"])
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"])
@@ -5,4 +5,6 @@ namespace :css do
5
5
  end
6
6
  end
7
7
 
8
- Rake::Task["assets:clobber"].enhance(["css:clobber"])
8
+ if Rake::Task.task_defined?("assets:clobber")
9
+ Rake::Task["assets:clobber"].enhance(["css:clobber"])
10
+ end
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: 0.2.8
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: 2021-12-12 00:00:00.000000000 Z
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.1.4
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.