critical-path-css-rails 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/critical_path_css/rails/config_loader.rb +3 -1
- data/lib/critical_path_css/rails/version.rb +1 -1
- data/spec/fixtures/files/config/manifest-and-path-both-specified.yml +10 -0
- data/spec/fixtures/files/config/manifest-and-paths-both-specified.yml +15 -0
- data/spec/lib/critical_path_css/rails/config_loader_spec.rb +16 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0977819dee8b4d3adb090674cd192ec08305a5a
|
4
|
+
data.tar.gz: bc12acec227acf35e7feb97c3029f9cd85bfb03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 545374b679ccd3795afe8c5eb44a1f2b4a60cb5cbbeda1a58b27a8c8f09fce963f68c00010d5cf611b03ef58d01018c7d1547852966caa60a1973a9bd8e623ed
|
7
|
+
data.tar.gz: 00074b868a74df74882f751e44533432dc9e1f9332b95b2e08e5d2206a32fe308c4e404b900466b61fe35413317697521bcd93c204740e4d80e357c37923c242
|
data/README.md
CHANGED
@@ -52,9 +52,11 @@ The generator adds the following files:
|
|
52
52
|
|
53
53
|
First, you'll need to configue a few things in the YAML file: `config/critical_path_css.yml`
|
54
54
|
|
55
|
+
**Note** that `manifest_name`, `css_path`, `css_paths` are all **mutually exclusive**; if using `css_path`, configuration for `manifest_name` AND `css_paths` should be omitted.
|
56
|
+
|
55
57
|
* `manifest_name`: If you're using the asset pipeline, add the manifest name.
|
56
58
|
* `css_path`: If you're not using the asset pipeline, you'll need to define the path to the application's main CSS. The gem assumes your CSS lives in `RAILS_ROOT/public`. If your main CSS file is in `RAILS_ROOT/public/assets/main.css`, you would set the variable to `/assets/main.css`.
|
57
|
-
* `css_paths`: If you have the need to specify multiple CSS source files, you can do so with `css_paths`.
|
59
|
+
* `css_paths`: If you have the need to specify multiple CSS source files, you can do so with `css_paths`. When using this option, a separate CSS path must be specified for each route, and they will be matched based on the order specified (the first CSS path will be applied to the first route, the second CSS path to the second route, etc).
|
58
60
|
* `routes`: List the routes that you would like to generate the critical CSS for. (i.e. /resources, /resources/show/1, etc.)
|
59
61
|
* `base_url`: Add your application's URL for the necessary environments.
|
60
62
|
|
@@ -33,7 +33,9 @@ module CriticalPathCss
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def validate_css_paths
|
36
|
-
if config['
|
36
|
+
if config['manifest_name'] && (config['css_path'] || config['css_paths'])
|
37
|
+
raise LoadError, 'Cannot specify both manifest_name and css_path(s)'
|
38
|
+
elsif config['css_path'] && config['css_paths']
|
37
39
|
raise LoadError, 'Cannot specify both css_path and css_paths'
|
38
40
|
elsif config['css_paths'] && config['css_paths'].length != config['routes'].length
|
39
41
|
raise LoadError, 'Must specify css_paths for each route'
|
@@ -32,6 +32,22 @@ RSpec.describe 'ConfigLoader' do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
context 'when manifest name and css path are both specified' do
|
36
|
+
let(:config_file) { file_fixture('config/manifest-and-path-both-specified.yml').read }
|
37
|
+
|
38
|
+
it 'raises an error' do
|
39
|
+
expect { subject }.to raise_error LoadError, 'Cannot specify both manifest_name and css_path(s)'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when manifest name and css paths are both specified' do
|
44
|
+
let(:config_file) { file_fixture('config/manifest-and-paths-both-specified.yml').read }
|
45
|
+
|
46
|
+
it 'raises an error' do
|
47
|
+
expect { subject }.to raise_error LoadError, 'Cannot specify both manifest_name and css_path(s)'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
35
51
|
context 'when single css_path and multiple css_paths are both specified' do
|
36
52
|
let(:config_file) { file_fixture('config/paths-both-specified.yml').read }
|
37
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: critical-path-css-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Misshore
|
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
- package-lock.json
|
69
69
|
- package.json
|
70
70
|
- spec/features/generate_and_fetch_critical_css_spec.rb
|
71
|
+
- spec/fixtures/files/config/manifest-and-path-both-specified.yml
|
72
|
+
- spec/fixtures/files/config/manifest-and-paths-both-specified.yml
|
71
73
|
- spec/fixtures/files/config/mutliple-css-paths.yml
|
72
74
|
- spec/fixtures/files/config/no-paths-specified.yml
|
73
75
|
- spec/fixtures/files/config/paths-and-routes-not-same-length.yml
|