cssbundling-rails 0.2.6 → 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: f839a506865e012ab4c918e645399aa34d8aa57fcc7376bbffbadcafb26d8ad7
4
- data.tar.gz: 712fa468fdf15ec1b2823e635c51b5f26f791cdfafb51bd94eb30b7ea5d549d5
3
+ metadata.gz: 63098c452d51cb9f77ad0729d5534865de3ea91d394086fdcdb63de5c6b75e71
4
+ data.tar.gz: f0d1b5c9f5fbfa97f5410d809df4726c034964ef174f17ab8d271879c6878a16
5
5
  SHA512:
6
- metadata.gz: c88eadeaab06974fce524d36aab035568c7a6432039957ed75b26f6305acf8c2f942f0abca7e836f52517c655468dc0ec55700fb51e8a9cf4f1511495b1185c7
7
- data.tar.gz: 57fd56159909dffac0267813154caec9bf788991597e6c1f87b1482dca4863bac68ce43093b02efa23500027fb0a6bd4249cd6655b4861c30a85730ecc425009
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 = "0.2.6"
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,8 @@ 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}")
26
+ run %(yarn build:css)
20
27
  end
@@ -7,7 +7,8 @@ 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
+ run %(yarn build:css)
13
14
  end
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,8 @@ 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
+ run %(yarn build:css)
13
14
  end
@@ -6,7 +6,8 @@ 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
+ run %(yarn build:css)
12
13
  end
@@ -4,10 +4,11 @@ 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
+ run %(yarn build:css)
13
14
  end
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
- mode: 'jit',
3
- purge: [
2
+ content: [
4
3
  './app/views/**/*.html.erb',
5
4
  './app/helpers/**/*.rb',
5
+ './app/assets/stylesheets/**/*.css',
6
6
  './app/javascript/**/*.js'
7
7
  ]
8
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"])
@@ -4,3 +4,7 @@ namespace :css do
4
4
  rm_rf Dir["app/assets/builds/[^.]*.css"], verbose: false
5
5
  end
6
6
  end
7
+
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: 0.2.6
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-11-17 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
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.2.22
78
+ rubygems_version: 3.2.32
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via