cssbundling-rails 0.2.2 → 0.2.6

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: c5be53848365bc063ba001b88c7e2f125b8f434dc0dff7b2bd2046cefeada38d
4
- data.tar.gz: 45502e231a93390c1fea3dccc6cb345b3ea63f1e57754906dc5c344a66fed61a
3
+ metadata.gz: f839a506865e012ab4c918e645399aa34d8aa57fcc7376bbffbadcafb26d8ad7
4
+ data.tar.gz: 712fa468fdf15ec1b2823e635c51b5f26f791cdfafb51bd94eb30b7ea5d549d5
5
5
  SHA512:
6
- metadata.gz: 5ce45e6fcfcf1262f4075f2e2729b0ac538e7e97a483f18547a04084e9b5444e07adb4e92f2aa88a73fe0b3b26aac5755335be7eb040dae6cc48bb0fa1487e67
7
- data.tar.gz: 7474397e610d94244b003e444342623b4d148f49f9a436775f63da856043d6c120be1d6ac9d316f6f559b6813eefc6b23c880b22450f155b9902ee3c61ca653b
6
+ metadata.gz: c88eadeaab06974fce524d36aab035568c7a6432039957ed75b26f6305acf8c2f942f0abca7e836f52517c655468dc0ec55700fb51e8a9cf4f1511495b1185c7
7
+ data.tar.gz: 57fd56159909dffac0267813154caec9bf788991597e6c1f87b1482dca4863bac68ce43093b02efa23500027fb0a6bd4249cd6655b4861c30a85730ecc425009
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.2"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -11,4 +11,10 @@ else
11
11
  end
12
12
 
13
13
  say "Add build:css script"
14
- run %(npm set-script build:css "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules")
14
+ build_script = "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
15
+
16
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
17
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
18
+ else
19
+ run %(npm set-script build:css "#{build_script}")
20
+ end
@@ -4,4 +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
- run %(npm set-script build:css "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
+
9
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
10
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
11
+ else
12
+ run %(npm set-script build:css "#{build_script}")
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
@@ -46,7 +46,7 @@ else
46
46
  say "Add default Procfile.dev"
47
47
  copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
48
48
 
49
- say "Ensure foreman is install"
49
+ say "Ensure foreman is installed"
50
50
  run "gem install foreman"
51
51
  end
52
52
 
@@ -1,7 +1,13 @@
1
- say "Install PostCSS w/ postcss-preset-env"
1
+ say "Install PostCSS w/ nesting and autoprefixer"
2
2
  copy_file "#{__dir__}/postcss.config.js", "postcss.config.js"
3
3
  copy_file "#{__dir__}/application.postcss.css", "app/assets/stylesheets/application.postcss.css"
4
- run "yarn add postcss postcss-cli postcss-preset-env"
4
+ run "yarn add postcss postcss-cli postcss-nesting autoprefixer"
5
5
 
6
6
  say "Add build:css script"
7
- run %(npm set-script build:css "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css")
7
+ build_script = "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css"
8
+
9
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
10
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
11
+ else
12
+ run %(npm set-script build:css "#{build_script}")
13
+ end
@@ -1,10 +1,6 @@
1
1
  module.exports = {
2
2
  plugins: [
3
- require('postcss-preset-env')({
4
- stage: 2,
5
- features: {
6
- 'nesting-rules': true
7
- }
8
- })
3
+ require('postcss-nesting'),
4
+ require('autoprefixer'),
9
5
  ],
10
6
  }
@@ -3,4 +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
- run %(npm set-script build:css "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
+
8
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
9
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
10
+ else
11
+ run %(npm set-script build:css "#{build_script}")
12
+ end
@@ -4,4 +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
- run %(npm set-script build:css "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"
8
+
9
+ if (`npx -v`.to_f < 7.1 rescue "Missing")
10
+ say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
11
+ else
12
+ run %(npm set-script build:css "#{build_script}")
13
+ end
@@ -1,7 +1,9 @@
1
1
  namespace :css do
2
2
  desc "Build your CSS bundle"
3
3
  task :build do
4
- system "yarn install && yarn build:css"
4
+ unless system "yarn install && yarn build:css"
5
+ raise "cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors"
6
+ end
5
7
  end
6
8
  end
7
9
 
@@ -0,0 +1,6 @@
1
+ namespace :css do
2
+ desc "Remove CSS builds"
3
+ task :clobber do
4
+ rm_rf Dir["app/assets/builds/[^.]*.css"], verbose: false
5
+ end
6
+ 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.2
4
+ version: 0.2.6
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-21 00:00:00.000000000 Z
12
+ date: 2021-11-17 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/clobber.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.