purgecss_sprockets 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/purgecss_sprockets/post_processor.rb +7 -1
- data/lib/purgecss_sprockets/version.rb +1 -1
- data/lib/purgecss_sprockets.rb +5 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45e40bd4dc8fda6902f31146f913065b0486dfbb321d4910d4c8328a51529d34
|
4
|
+
data.tar.gz: f863ea707eae8defebb2da071cb3cd26aa1d6e602ff09ff9345a36b7a2e9909b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab46822c1fa8a13f1c09f6317c1dd531ea3b224b3efe18cc3691c3a0d6744019b1858bfce6a7e5424db04013126cf1906e245d5b6beac70629bbf5aab1ed55b9
|
7
|
+
data.tar.gz: 2c3fb1953f2892e1c33051d52f76f91473df46c2a8ef77933e89f1ee48673dcbb5f8ecb6456fe478a73f6612f116940c15ccc43378cbd0fd40816f4ed2d34051
|
data/README.md
CHANGED
@@ -45,8 +45,26 @@ PurgecssSprockets.disabled = true # default: false
|
|
45
45
|
PurgecssSprockets.purgecss_cmd = "node node_modules/purgecss/bin/purgecss.js"
|
46
46
|
```
|
47
47
|
|
48
|
+
You can exclude some entrypoints by filling the `exclude_files` in the initializer:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
PurgecssSprockets.exclude_files = %w(
|
52
|
+
app/assets/stylesheets/admin.sass
|
53
|
+
)
|
54
|
+
```
|
55
|
+
|
48
56
|
You can configure PurgeCSS with the generated `purgecss.config.js`.
|
49
57
|
|
58
|
+
## Debug
|
59
|
+
|
60
|
+
- In an initializer, disable the PurgecssSprockets' post-processor.
|
61
|
+
- Run `rails assets:clobber assets:precompile`
|
62
|
+
- Open a Rails console and run this:
|
63
|
+
```ruby
|
64
|
+
json = JSON.parse(`node node_modules/purgecss/bin/purgecss.js --css public/assets/[your-digested-css-file].css --config purgecss.config.js --rejected`)[0]
|
65
|
+
```
|
66
|
+
- You can now check which selectors are rejected by PurgeCSS in `json['rejected']`.
|
67
|
+
|
50
68
|
## Development
|
51
69
|
|
52
70
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -12,8 +12,14 @@ module PurgecssSprockets
|
|
12
12
|
def self.run(filename, source, context)
|
13
13
|
return source if PurgecssSprockets.disabled
|
14
14
|
|
15
|
+
filepath_from_root = filename.gsub("#{Rails.root}/", '')
|
15
16
|
if context && context.environment
|
16
|
-
|
17
|
+
if PurgecssSprockets.exclude_files.include?(filepath_from_root)
|
18
|
+
context.environment.logger&.info "Skipping CSS purge of #{filename}"
|
19
|
+
return source
|
20
|
+
else
|
21
|
+
context.environment.logger&.info "Purging CSS from #{filename}"
|
22
|
+
end
|
17
23
|
end
|
18
24
|
|
19
25
|
file = Tempfile.new(filename)
|
data/lib/purgecss_sprockets.rb
CHANGED
@@ -7,12 +7,16 @@ module PurgecssSprockets
|
|
7
7
|
class Error < StandardError; end
|
8
8
|
|
9
9
|
class << self
|
10
|
-
attr_writer :disabled, :purgecss_cmd
|
10
|
+
attr_writer :disabled, :exclude_files, :purgecss_cmd
|
11
11
|
|
12
12
|
def disabled
|
13
13
|
@disabled ||= false
|
14
14
|
end
|
15
15
|
|
16
|
+
def exclude_files
|
17
|
+
@exclude_files ||= []
|
18
|
+
end
|
19
|
+
|
16
20
|
def purgecss_cmd
|
17
21
|
@purgecss_cmd ||= "node node_modules/purgecss/bin/purgecss.js"
|
18
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purgecss_sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Gaya
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -67,7 +67,7 @@ licenses:
|
|
67
67
|
metadata:
|
68
68
|
homepage_uri: https://github.com/noesya/purgecss_sprockets
|
69
69
|
source_code_uri: https://github.com/noesya/purgecss_sprockets
|
70
|
-
post_install_message:
|
70
|
+
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
@@ -82,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
86
|
-
signing_key:
|
85
|
+
rubygems_version: 3.2.32
|
86
|
+
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Use PurgeCSS in Rails asset pipeline.
|
89
89
|
test_files: []
|