cssbundling-rails 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/cssbundling/version.rb +1 -1
- data/lib/install/Procfile.dev +1 -1
- data/lib/install/bootstrap/install.rb +28 -8
- data/lib/install/bulma/install.rb +7 -3
- data/lib/install/dev +3 -4
- data/lib/install/postcss/install.rb +7 -3
- data/lib/install/sass/install.rb +7 -3
- data/lib/install/tailwind/install.rb +7 -3
- data/lib/tasks/cssbundling/build.rake +12 -8
- data/lib/tasks/cssbundling/clobber.rake +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eb8589b682d3c0c276c75baa0923c706e3f09de2a554e47ea7f008e01b555c5
|
4
|
+
data.tar.gz: c8c43687d5cbf5cf3fc7f2e7fcbeb35f99b80e2986227135e306cb4a42167423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e4959bbf33a9b580f33a8316a327f437b3ce422d69a95e2e7c55df99e2fc840e98eb636c6baa9e281421415c62e5de28e42d39db2d1b0440db46895f498959
|
7
|
+
data.tar.gz: ee626b8d3329f131034b218ccac7c5590d36afa7d4191b75afa0a06ed5f27268fe5c1720cdd64d347102ec71d5bdff34c993d12b460030064802c0ccc6d71899
|
data/README.md
CHANGED
@@ -8,9 +8,7 @@ Whenever the bundler detects changes to any of the stylesheet files in your proj
|
|
8
8
|
|
9
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.
|
10
10
|
|
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.
|
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. If your setup uses [jsbundling-rails](https://github.com/rails/jsbundling-rails) (ie, esbuild + tailwind), you will also need to run `javascript:build`.
|
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. If your test framework does not call the `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
12
|
|
15
13
|
That's it!
|
16
14
|
|
@@ -45,6 +43,14 @@ Some CSS packages use new CSS features that are not supported by the default Sas
|
|
45
43
|
|
46
44
|
A common issue is that your repository does not contain the output directory used by the build commands. You must have `app/assets/builds` available. Add the directory with a `.gitkeep` file, and you'll ensure it's available in production.
|
47
45
|
|
46
|
+
### Why isn't Rails using my updated css files?
|
47
|
+
|
48
|
+
Watch out - if you precompile your files locally, those will be served over the dynamically created ones you expect. The solution:
|
49
|
+
|
50
|
+
```shell
|
51
|
+
rails assets:clobber
|
52
|
+
```
|
53
|
+
|
48
54
|
## License
|
49
55
|
|
50
56
|
CSS Bundling for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/cssbundling/version.rb
CHANGED
data/lib/install/Procfile.dev
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
web: bin/rails server
|
1
|
+
web: unset PORT && env RUBY_DEBUG_OPEN=true bin/rails server
|
2
2
|
css: yarn build:css --watch
|
@@ -1,7 +1,7 @@
|
|
1
|
-
say "Install Bootstrap with Bootstrap Icons
|
1
|
+
say "Install Bootstrap with Bootstrap Icons, Popperjs/core and Autoprefixer"
|
2
2
|
copy_file "#{__dir__}/application.bootstrap.scss",
|
3
3
|
"app/assets/stylesheets/application.bootstrap.scss"
|
4
|
-
run "yarn add sass bootstrap bootstrap-icons @popperjs/core"
|
4
|
+
run "yarn add sass bootstrap bootstrap-icons @popperjs/core postcss postcss-cli autoprefixer nodemon"
|
5
5
|
|
6
6
|
inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do
|
7
7
|
<<~RUBY
|
@@ -16,12 +16,32 @@ else
|
|
16
16
|
say %(Add import * as bootstrap from "bootstrap" to your entry point JavaScript file), :red
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
def add_npm_script(name, script, run_script=true)
|
20
|
+
case `npx -v`.to_f
|
21
|
+
when 7.1...8.0
|
22
|
+
say "Add #{name} script"
|
23
|
+
run %(npm set-script #{name} "#{script}")
|
24
|
+
run %(yarn #{name}) if run_script
|
25
|
+
when (8.0..)
|
26
|
+
say "Add #{name} script"
|
27
|
+
run %(npm pkg set scripts.#{name}="#{script}")
|
28
|
+
run %(yarn #{name}) if run_script
|
29
|
+
else
|
30
|
+
say %(Add "scripts": { "#{name}": "#{script}" } to your package.json), :green
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
add_npm_script("build:css:compile", "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules")
|
35
|
+
add_npm_script("build:css:prefix", "postcss ./app/assets/builds/application.css --use=autoprefixer --output=./app/assets/builds/application.css")
|
36
|
+
add_npm_script("build:css", "yarn build:css:compile && yarn build:css:prefix")
|
37
|
+
add_npm_script("watch:css", "nodemon --watch ./app/assets/stylesheets/ --ext scss --exec \\\"yarn build:css\\\"", false)
|
38
|
+
|
39
|
+
gsub_file "Procfile.dev", "build:css --watch", "watch:css"
|
21
40
|
|
22
|
-
|
23
|
-
|
41
|
+
case `npx -v`.to_f
|
42
|
+
when (7.1..)
|
43
|
+
say "Add browserslist config"
|
44
|
+
run %(npm pkg set browserslist[]=defaults)
|
24
45
|
else
|
25
|
-
|
26
|
-
run %(yarn build:css)
|
46
|
+
say %(Add "browserslist": ["defaults"] to your package.json), :green
|
27
47
|
end
|
@@ -6,9 +6,13 @@ run "yarn add sass bulma"
|
|
6
6
|
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
|
-
|
10
|
-
|
11
|
-
else
|
9
|
+
case `npx -v`.to_f
|
10
|
+
when 7.1...8.0
|
12
11
|
run %(npm set-script build:css "#{build_script}")
|
13
12
|
run %(yarn build:css)
|
13
|
+
when (8.0..)
|
14
|
+
run %(npm pkg set scripts.build:css="#{build_script}")
|
15
|
+
run %(yarn build:css)
|
16
|
+
else
|
17
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
|
14
18
|
end
|
data/lib/install/dev
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env sh
|
2
2
|
|
3
|
-
if ! foreman
|
4
|
-
then
|
3
|
+
if ! gem list foreman -i --silent; then
|
5
4
|
echo "Installing foreman..."
|
6
5
|
gem install foreman
|
7
6
|
fi
|
8
7
|
|
9
|
-
foreman start -f Procfile.dev "$@"
|
8
|
+
exec foreman start -f Procfile.dev "$@"
|
@@ -6,9 +6,13 @@ run "yarn add postcss postcss-cli postcss-nesting autoprefixer"
|
|
6
6
|
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
|
-
|
10
|
-
|
11
|
-
else
|
9
|
+
case `npx -v`.to_f
|
10
|
+
when 7.1...8.0
|
12
11
|
run %(npm set-script build:css "#{build_script}")
|
13
12
|
run %(yarn build:css)
|
13
|
+
when (8.0..)
|
14
|
+
run %(npm pkg set scripts.build:css="#{build_script}")
|
15
|
+
run %(yarn build:css)
|
16
|
+
else
|
17
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
|
14
18
|
end
|
data/lib/install/sass/install.rb
CHANGED
@@ -5,9 +5,13 @@ run "yarn add sass"
|
|
5
5
|
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
|
-
|
9
|
-
|
10
|
-
else
|
8
|
+
case `npx -v`.to_f
|
9
|
+
when 7.1...8.0
|
11
10
|
run %(npm set-script build:css "#{build_script}")
|
12
11
|
run %(yarn build:css)
|
12
|
+
when (8.0..)
|
13
|
+
run %(npm pkg set scripts.build:css="#{build_script}")
|
14
|
+
run %(yarn build:css)
|
15
|
+
else
|
16
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
|
13
17
|
end
|
@@ -6,9 +6,13 @@ run "yarn add tailwindcss@latest postcss@latest autoprefixer@latest"
|
|
6
6
|
say "Add build:css script"
|
7
7
|
build_script = "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
else
|
9
|
+
case `npx -v`.to_f
|
10
|
+
when 7.1...8.0
|
12
11
|
run %(npm set-script build:css "#{build_script}")
|
13
12
|
run %(yarn build:css)
|
13
|
+
when (8.0..)
|
14
|
+
run %(npm pkg set scripts.build:css="#{build_script}")
|
15
|
+
run %(yarn build:css)
|
16
|
+
else
|
17
|
+
say %(Add "scripts": { "build:css": "#{build_script}" } to your package.json), :green
|
14
18
|
end
|
@@ -2,17 +2,21 @@ namespace :css do
|
|
2
2
|
desc "Build your CSS bundle"
|
3
3
|
task :build do
|
4
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"
|
5
|
+
raise "cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors or use SKIP_CSS_BUILD env variable"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
Rake::Task
|
12
|
-
|
10
|
+
unless ENV["SKIP_CSS_BUILD"]
|
11
|
+
if Rake::Task.task_defined?("assets:precompile")
|
12
|
+
Rake::Task["assets:precompile"].enhance(["css:build"])
|
13
|
+
end
|
13
14
|
|
14
|
-
if Rake::Task.task_defined?("test:prepare")
|
15
|
-
|
16
|
-
elsif Rake::Task.task_defined?("
|
17
|
-
|
15
|
+
if Rake::Task.task_defined?("test:prepare")
|
16
|
+
Rake::Task["test:prepare"].enhance(["css:build"])
|
17
|
+
elsif Rake::Task.task_defined?("spec:prepare")
|
18
|
+
Rake::Task["spec:prepare"].enhance(["css:build"])
|
19
|
+
elsif Rake::Task.task_defined?("db:test:prepare")
|
20
|
+
Rake::Task["db:test:prepare"].enhance(["css:build"])
|
21
|
+
end
|
18
22
|
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: 1.
|
4
|
+
version: 1.2.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:
|
12
|
+
date: 2023-06-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.
|
78
|
+
rubygems_version: 3.4.10
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Bundle and process CSS with Tailwind, Bootstrap, PostCSS, Sass in Rails via
|