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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f685e725bac129b8bb2a3bfc069f4c6015e0a406ede20cd444c8325d2585c5d
4
- data.tar.gz: 631c009e5bae4675a5e0c186af3988052bde74500c7f5220cc8e8d5034d58ed3
3
+ metadata.gz: 63098c452d51cb9f77ad0729d5534865de3ea91d394086fdcdb63de5c6b75e71
4
+ data.tar.gz: f0d1b5c9f5fbfa97f5410d809df4726c034964ef174f17ab8d271879c6878a16
5
5
  SHA512:
6
- metadata.gz: 926234cd4a186306054b1880eecf4d716b1b6209ec5187916738e92259f0a3b026d90bce3e6f1face9723c9159e59625a23c53800516df407c1184396eaf0a16
7
- data.tar.gz: 376bcaa584131363bb673617e2fbb45ab21c5b61e6cf9483b348327edd32c3b63511d4990e15af9f4d2aad7bf909035602c142e1128c4e9723f0331ab2e3df96
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" %>`.
@@ -1,3 +1,3 @@
1
1
  module Cssbundling
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
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"
@@ -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), :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)
@@ -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), :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
@@ -6,4 +6,4 @@ then
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)
@@ -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), :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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cssbundling-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
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: 2021-12-14 00:00:00.000000000 Z
12
+ date: 2022-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties