cssbundling-rails 0.1.4 → 0.1.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: 8c82ef361bd3cc309f18f8409933e815eec239fd35bd7da36b8efbce95836b1d
4
- data.tar.gz: '08a38e4931966664bcb64946fc30f8b87130d4d38e76aed116fc52dddca63448'
3
+ metadata.gz: f1cb16bc8fd46769c9ceee9130fe3146da522850768c6d004043cab54fa45595
4
+ data.tar.gz: cd894d657fcc8d2d55c14d61674f85627ea6e7cb0d3d2375c1d8ea5529f531b4
5
5
  SHA512:
6
- metadata.gz: 9bd72320a3937f2f07744b4ec6543313bf8892b3b19894061ac96ee129700c682ca2f72624b4498b4399206da2edeb84ed01280deb270ea0b58d1707c519855d
7
- data.tar.gz: 4bff61453f9b2e847dcc0284221376d04f26323f68863f91f1e6d338fae5b7c91f5d9da27911dddfaaf1bf75d034cd08434cba4748d06feb949db49e9050694d
6
+ metadata.gz: ef825dd44a3654b15d488894b19f01020be3020129a2ba45934b5e7860f17824120336109dc15de9a109c6d3e0bf080b0686bed761ade6d29314bb238a905d96
7
+ data.tar.gz: 2b7c58fb054093ad72f89b34472ae38b0a33ea9a16b4565139d90860c6cb1affa890fac65e7530f37ae626bcf2d8f718072cabe752b637990cf1354b6b295ecd
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), [PostCSS](https://postcss.org), [Dart Sass](https://sass-lang.com/), or [Bootstrap](https://getbootstrap.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|postcss|sass|bootstrap]`
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|postcss|sass|bootstrap]`.
25
27
 
26
28
 
27
29
  ## License
@@ -1,3 +1,3 @@
1
1
  module Cssbundling
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
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,6 +3,9 @@ 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", ""
8
+
6
9
  if Rails.root.join(".gitignore").exist?
7
10
  append_to_file(".gitignore", %(/app/assets/builds\n!/app/assets/builds/.keep\n))
8
11
  end
@@ -27,3 +30,4 @@ end
27
30
 
28
31
  say "Add bin/dev to start foreman"
29
32
  copy_file "#{__dir__}/dev", "bin/dev"
33
+ 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,4 @@ 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
+ Rake::Task["test:prepare"].enhance(["css:build"]) if Rake::Task.task_defined?("test:prepare")
@@ -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.5
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-09-08 00:00:00.000000000 Z
12
+ date: 2021-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -37,6 +37,8 @@ files:
37
37
  - lib/cssbundling/engine.rb
38
38
  - lib/cssbundling/version.rb
39
39
  - lib/install/Procfile.dev
40
+ - lib/install/bootstrap/application.bootstrap.scss
41
+ - lib/install/bootstrap/install.rb
40
42
  - lib/install/dev
41
43
  - lib/install/install.rb
42
44
  - lib/install/package.json