cssbundling-rails 0.1.4 → 0.1.8

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: 8c82ef361bd3cc309f18f8409933e815eec239fd35bd7da36b8efbce95836b1d
4
- data.tar.gz: '08a38e4931966664bcb64946fc30f8b87130d4d38e76aed116fc52dddca63448'
3
+ metadata.gz: a70423b8588a0b537518131ad10a0a702e5891343a3800ac099c13de2a2b8e1f
4
+ data.tar.gz: 237ee6613b56c3296a1ad95b78cdb6bac8cd78a900879f006ce06c1ec314fca8
5
5
  SHA512:
6
- metadata.gz: 9bd72320a3937f2f07744b4ec6543313bf8892b3b19894061ac96ee129700c682ca2f72624b4498b4399206da2edeb84ed01280deb270ea0b58d1707c519855d
7
- data.tar.gz: 4bff61453f9b2e847dcc0284221376d04f26323f68863f91f1e6d338fae5b7c91f5d9da27911dddfaaf1bf75d034cd08434cba4748d06feb949db49e9050694d
6
+ metadata.gz: 005d6451373ec31e23cdca38b8f75bd32426bcabb94bc7c7d88675e682a24c75a104b8fcab0725806503f22cf04c388fe25bdb2ffd67ff92871856f711576ef3
7
+ data.tar.gz: '08966254d0702d793a7f09322b8a01820c42a5cc76d23ee4d6cc991a849a23be5a548329f7c804afcbeff422b672689cff1b49a4de66a57bc3f25f2f32b74d85'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CSS Bundling for Rails
2
2
 
3
- Use [Tailwind CSS](https://tailwindcss.com), [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).
3
+ Use [Tailwind CSS](https://tailwindcss.com), [Bootstrap](https://getbootstrap.com/), [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
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" %>`.
6
6
 
@@ -8,6 +8,8 @@ When you deploy your application to production, the `css:build` task attaches to
8
8
 
9
9
  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`).
10
10
 
11
+ 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.
12
+
11
13
  That's it!
12
14
 
13
15
  You can configure your bundler options in the `build:css` script in `package.json` or via the installer-generated `tailwind.config.js` for Tailwind or `postcss.config.js` for PostCSS.
@@ -19,9 +21,9 @@ You must already have node and yarn installed on your system. You will also need
19
21
 
20
22
  1. Add `cssbundling-rails` to your Gemfile with `gem 'cssbundling-rails'`
21
23
  2. Run `./bin/bundle install`
22
- 3. Run `./bin/rails css:install:[tailwind|postcss|sass]`
24
+ 3. Run `./bin/rails css:install:[tailwind|bootstrap|postcss|sass]`
23
25
 
24
- Or, in Rails 7+, you can preconfigure your new application to use a specific bundler with `rails new myapp --css [tailwind|postcss|sass]`.
26
+ Or, in Rails 7+, you can preconfigure your new application to use a specific bundler with `rails new myapp --css [tailwind|bootstrap|postcss|sass]`.
25
27
 
26
28
 
27
29
  ## License
@@ -1,3 +1,3 @@
1
1
  module Cssbundling
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -0,0 +1 @@
1
+ @import 'bootstrap/scss/bootstrap';
@@ -0,0 +1,14 @@
1
+ say "Install Bootstrap with Popperjs/core"
2
+ copy_file "#{__dir__}/application.bootstrap.scss",
3
+ "app/assets/stylesheets/application.bootstrap.scss"
4
+ run "yarn add sass bootstrap @popperjs/core"
5
+
6
+ if Rails.root.join("app/javascript/application.js").exist?
7
+ say "Appending Bootstrap JavaScript import to default entry point"
8
+ append_to_file "app/javascript/application.js", %(import * as bootstrap from "bootstrap"\n)
9
+ else
10
+ say %(Add import * as bootstrap from "bootstrap" to your entry point JavaScript file), :red
11
+ end
12
+
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")
@@ -3,20 +3,42 @@ empty_directory "app/assets/builds"
3
3
  keep_file "app/assets/builds"
4
4
  append_to_file "app/assets/config/manifest.js", %(//= link_tree ../builds\n)
5
5
 
6
+ say "Stop linking stylesheets automatically"
7
+ gsub_file "app/assets/config/manifest.js", "//= link_directory ../stylesheets .css\n", ""
8
+
6
9
  if Rails.root.join(".gitignore").exist?
7
- append_to_file(".gitignore", %(/app/assets/builds\n!/app/assets/builds/.keep\n))
10
+ append_to_file(".gitignore", %(\n/app/assets/builds/*\n!/app/assets/builds/.keep\n))
11
+ append_to_file(".gitignore", %(\n/node_modules\n))
8
12
  end
9
13
 
10
14
  say "Remove app/assets/stylesheets/application.css so build output can take over"
11
15
  remove_file "app/assets/stylesheets/application.css"
12
16
 
17
+ if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
18
+ say "Add stylesheet link tag in application layout"
19
+ insert_into_file(
20
+ app_layout_path.to_s,
21
+ defined?(Turbo) ?
22
+ %(\n <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>) :
23
+ %(\n <%= stylesheet_link_tag "application" %>),
24
+ before: /\s*<\/head>/
25
+ )
26
+ else
27
+ say "Default application.html.erb is missing!", :red
28
+ if defined?(Turbo)
29
+ say %( Add <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
30
+ else
31
+ say %( Add <%= stylesheet_link_tag "application" %> within the <head> tag in your custom layout.)
32
+ end
33
+ end
34
+
13
35
  unless Rails.root.join("package.json").exist?
14
36
  say "Add default package.json"
15
37
  copy_file "#{__dir__}/package.json", "package.json"
16
38
  end
17
39
 
18
40
  if Rails.root.join("Procfile.dev").exist?
19
- append_to_file "Procfile.dev", "css: yarn build:css --watch"
41
+ append_to_file "Procfile.dev", "\ncss: yarn build:css --watch"
20
42
  else
21
43
  say "Add default Procfile.dev"
22
44
  copy_file "#{__dir__}/Procfile.dev", "Procfile.dev"
@@ -27,3 +49,4 @@ end
27
49
 
28
50
  say "Add bin/dev to start foreman"
29
51
  copy_file "#{__dir__}/dev", "bin/dev"
52
+ chmod "bin/dev", 0755, verbose: false
@@ -3,4 +3,4 @@ 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")
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,4 +6,9 @@ namespace :css do
6
6
  end
7
7
 
8
8
  Rake::Task["assets:precompile"].enhance(["css:build"])
9
- Rake::Task["test:prepare"].enhance(["css:build"])
9
+
10
+ if Rake::Task.task_defined?("test:prepare")
11
+ Rake::Task["test:prepare"].enhance(["css:build"])
12
+ elsif Rake::Task.task_defined?("db:test:prepare")
13
+ Rake::Task["db:test:prepare"].enhance(["css:build"])
14
+ end
@@ -19,5 +19,10 @@ namespace :css do
19
19
  task sass: "css:install:shared" do
20
20
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/sass/install.rb", __dir__)}"
21
21
  end
22
+
23
+ desc "Install Bootstrap"
24
+ task bootstrap: "css:install:shared" do
25
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/bootstrap/install.rb", __dir__)}"
26
+ end
22
27
  end
23
28
  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.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-08 00:00:00.000000000 Z
12
+ date: 2021-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
15
+ name: railties
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 6.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: sprockets-rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0
28
42
  description:
29
43
  email: david@loudthinking.com
30
44
  executables: []
@@ -37,6 +51,8 @@ files:
37
51
  - lib/cssbundling/engine.rb
38
52
  - lib/cssbundling/version.rb
39
53
  - lib/install/Procfile.dev
54
+ - lib/install/bootstrap/application.bootstrap.scss
55
+ - lib/install/bootstrap/install.rb
40
56
  - lib/install/dev
41
57
  - lib/install/install.rb
42
58
  - lib/install/package.json
@@ -73,5 +89,6 @@ requirements: []
73
89
  rubygems_version: 3.1.4
74
90
  signing_key:
75
91
  specification_version: 4
76
- summary: Bundle and process CSS with Tailwind, PostCSS, or Sass in Rails via Node.js.
92
+ summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via
93
+ Node.js.
77
94
  test_files: []