cssbundling-rails 0.2.4 → 0.2.5

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: 2327f824df0a60b8114f3834b29a7d20b005bb2645d98083772ca1fa622b8d8c
4
- data.tar.gz: 1bf817470b20cbe122c67a3b502ebdea182a7c526073b0059f05b6c262af5203
3
+ metadata.gz: 17fa9455564f88e8e8ea4034a948bdcd641be3108ac6e9eb8244a2515877971e
4
+ data.tar.gz: 87b5fa05bff61fb65e70ada26275be1e807734ad68af54c345dffe9aa6c893fc
5
5
  SHA512:
6
- metadata.gz: c01ddba4ef303e6a03f59480709003950deeaad59238d7afd974009fa18914e872be4aa19ddd2ba7c976124bc06aad5f3fc6016e98672b4162feed7016e06826
7
- data.tar.gz: cd093d2443110526f411698cbbabab0e222e3c81221f6a95139a04ef8bd0197d70de9a27aa8081ae3010e33888e1e5207c2bd693fa7a4bc1b70c432bd6af66b3
6
+ metadata.gz: 13e364e934c7ef424a5ad2d5f62c593c689185fa333fd283b53173183511bcad112177ec5a46a297f2e8fda06ce3d21616eb70e57df8b245bd5299586494a5d5
7
+ data.tar.gz: b03e89051ca7dfd506b4a8a861ea1b81d9979974e84421e62b5a987a61a2b4f60ec0d90fdfee3eefca1c308d022a06040e5604402dbcb6ae0bdc985c55da7789
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Use [Tailwind CSS](https://tailwindcss.com), [Bootstrap](https://getbootstrap.com/), [Bulma](https://bulma.io/), [PostCSS](https://postcss.org), or [Dart Sass](https://sass-lang.com/) to bundle and process your CSS, then deliver it via the asset pipeline in Rails. This gem provides installers to get you going with the bundler of your choice in a new Rails application, and a convention to use `app/assets/builds` to hold your bundled output as artifacts that are not checked into source control (the installer adds this directory to `.gitignore` by default).
4
4
 
5
- You develop using this approach by running the bundler in watch mode in a terminal with `yarn build:css --watch` (and your Rails server in another, if you're not using something like [puma-dev](https://github.com/puma/puma-dev)). Whenever the bundler detects changes to any of the stylesheet files in your project, it'll bundle `app/assets/stylesheets/application.[bundler].css` into `app/assets/builds/application.css`. This build output takes over from the regular asset pipeline default file. So you continue to refer to the build output in your layout using the standard asset pipeline approach with `<%= stylesheet_link_tag "application" %>`.
5
+ You develop using this approach by running the bundler in watch mode in a terminal with `yarn build:css --watch` (and your Rails server in another, if you're not using something like [puma-dev](https://github.com/puma/puma-dev)). You can also use `./bin/dev`, which will start both the Rails server and the CSS build watcher (along with a JS build watcher, if you're also using `jsbundling-rails`).
6
+
7
+ Whenever the bundler detects changes to any of the stylesheet files in your project, it'll bundle `app/assets/stylesheets/application.[bundler].css` into `app/assets/builds/application.css`. This build output takes over from the regular asset pipeline default file. So you continue to refer to the build output in your layout using the standard asset pipeline approach with `<%= stylesheet_link_tag "application" %>`.
6
8
 
7
9
  When you deploy your application to production, the `css:build` task attaches to the `assets:precompile` task to ensure that all your package dependencies from `package.json` have been installed via yarn, and then runs `yarn build:css` to process your stylesheet entrypoint, as it would in development. This output is then picked up by the asset pipeline, digested, and copied into public/assets, as any other asset pipeline file.
8
10
 
@@ -26,6 +28,16 @@ You must already have node and yarn installed on your system. You will also need
26
28
  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]`.
27
29
 
28
30
 
31
+ ## FAQ
32
+
33
+ ### How do I import relative CSS files with Tailwind?
34
+
35
+ 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" %>`.
36
+
37
+ ### How do I avoid SassC::SyntaxError exceptions on existing projects?
38
+
39
+ 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
+
29
41
  ## License
30
42
 
31
43
  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.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -14,7 +14,7 @@ say "Add build:css script"
14
14
  build_script = "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
15
15
 
16
16
  if (`npx -v`.to_f < 7.1 rescue "Missing")
17
- say %(Add "scripts": { "build:css": "#{build_script}" to your package.json), :green
17
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
18
18
  else
19
19
  run %(npm set-script build:css "#{build_script}")
20
20
  end
@@ -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), :green
11
11
  else
12
12
  run %(npm set-script build:css "#{build_script}")
13
13
  end
data/lib/install/dev CHANGED
@@ -1,3 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ if ! command -v foreman &> /dev/null
4
+ then
5
+ echo "Installing foreman..."
6
+ gem install foreman
7
+ fi
8
+
3
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), :green
11
11
  else
12
12
  run %(npm set-script build:css "#{build_script}")
13
13
  end
@@ -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), :green
10
10
  else
11
11
  run %(npm set-script build:css "#{build_script}")
12
12
  end
@@ -7,7 +7,7 @@ say "Add build:css script"
7
7
  build_script = "tailwindcss -i ./app/assets/stylesheets/application.tailwind.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), :green
11
11
  else
12
12
  run %(npm set-script build:css "#{build_script}")
13
13
  end
@@ -1,7 +1,7 @@
1
1
  namespace :css do
2
2
  desc "Build your CSS bundle"
3
- task :build do
4
- unless system "yarn install && yarn build:css"
3
+ task build: [ "yarn:install" ] do
4
+ unless system "yarn build:css"
5
5
  raise "cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors"
6
6
  end
7
7
  end
@@ -0,0 +1,8 @@
1
+ namespace :css do
2
+ desc "Remove CSS builds"
3
+ task :clean do
4
+ rm_rf Dir["app/assets/builds/[^.]*.css"], verbose: false
5
+ end
6
+ end
7
+
8
+ Rake::Task["assets:clean"].enhance(["css:clean"])
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.4
4
+ version: 0.2.5
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-09-29 00:00:00.000000000 Z
12
+ date: 2021-11-15 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: []
@@ -54,12 +54,13 @@ files:
54
54
  - lib/install/tailwind/package.json
55
55
  - lib/install/tailwind/tailwind.config.js
56
56
  - lib/tasks/cssbundling/build.rake
57
+ - lib/tasks/cssbundling/clean.rake
57
58
  - lib/tasks/cssbundling/install.rake
58
59
  homepage: https://github.com/rails/cssbundling-rails
59
60
  licenses:
60
61
  - MIT
61
62
  metadata: {}
62
- post_install_message:
63
+ post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
65
66
  - lib
@@ -74,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.1.4
78
- signing_key:
78
+ rubygems_version: 3.2.22
79
+ signing_key:
79
80
  specification_version: 4
80
81
  summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via
81
82
  Node.js.