faucet_pipeline_rails 1.0.0.rc0 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +36 -40
- data/lib/faucet_pipeline_rails/manifest.rb +9 -9
- data/lib/faucet_pipeline_rails/railtie.rb +14 -0
- data/lib/faucet_pipeline_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f6b20abd70b0ea93f17dae2277531b6dda7b6c
|
4
|
+
data.tar.gz: 4036e53601582fc1f6eb435ebba0943f08d4c55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619f4e6bb2956cfb3cb5665cc03a4bc00380ebea0b2d1bb55ba470d18c45ff7257acfa62d477c9dbabe67eac7c6279a9d26cecea72068c84631875f125d5764f
|
7
|
+
data.tar.gz: 59baa88114aca729e561adb917b7dbdd74f11b1af5678add07363ea6ff0db8676c7b75ec66339c9bbccbf352d061068c0d11be2901dd69d9a6e4139c009425b3
|
data/README.md
CHANGED
@@ -18,11 +18,10 @@ So let's say you have a JavaScript file called `application.js` (for example in
|
|
18
18
|
`app/assets/javascripts`) and `faucet-pipeline` generates a file called
|
19
19
|
`application-03118e77692b637cfc0f55bb27fef087.js` (for example in
|
20
20
|
`public/assets/javascripts`) from that file. When you use `stylesheet_link_tag
|
21
|
-
'
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
the Configuration section)
|
21
|
+
'application.css'`, you expect that the resulting HTML points to the file
|
22
|
+
containing the hash in its filename. To do that, `faucet-pipeline` generates a
|
23
|
+
manifest file. In the case of using it with this Gem, it needs to save it as
|
24
|
+
`public/assets/manifest.json` (to change this, see the Configuration section)
|
26
25
|
|
27
26
|
And that's it. This gem will take care of the rest. The resulting HTML will
|
28
27
|
look like this:
|
@@ -53,14 +52,8 @@ And then execute:
|
|
53
52
|
$ bundle
|
54
53
|
```
|
55
54
|
|
56
|
-
Or install it yourself as:
|
57
|
-
|
58
|
-
```
|
59
|
-
$ gem install faucet_pipeline_rails
|
60
|
-
```
|
61
|
-
|
62
55
|
After this, you can ditch sprockets (aka the classic Rails asset pipeline)
|
63
|
-
for good. If you're on an existing Rails app, change the top of your
|
56
|
+
for good. If you're on an existing Rails app, change the top of your
|
64
57
|
`config/application.rb` from `require 'rails/all'` to:
|
65
58
|
|
66
59
|
```ruby
|
@@ -83,54 +76,57 @@ For fresh apps, you can just skip sprockets with:
|
|
83
76
|
|
84
77
|
rails new --skip-sprockets
|
85
78
|
|
79
|
+
You also need to install `faucet-pipeline`.
|
80
|
+
[Here are the instructions](http://www.faucet-pipeline.org)
|
81
|
+
|
86
82
|
## Configuration
|
87
83
|
|
88
|
-
|
89
|
-
`public/assets/manifest.json`. This is a nice starting point for a
|
90
|
-
`faucet.config.js`:
|
84
|
+
This is a nice starting point for a `faucet.config.js`:
|
91
85
|
|
92
86
|
```js
|
93
|
-
let jsConfig = [{
|
94
|
-
entryPoint: "./app/assets/javascripts/application.js",
|
95
|
-
target: "./public/assets/javascripts/application.js"
|
96
|
-
}];
|
97
|
-
|
98
|
-
let sassConfig = [{
|
99
|
-
entryPoint: "./app/assets/stylesheets/application.scss",
|
100
|
-
target: "./public/assets/stylesheets/application.css"
|
101
|
-
}];
|
102
|
-
|
103
|
-
let staticConfig = [{
|
104
|
-
source: "./app/assets/images",
|
105
|
-
target: "./public/assets/images"
|
106
|
-
}];
|
107
|
-
|
108
87
|
module.exports = {
|
109
|
-
js:
|
110
|
-
|
111
|
-
|
112
|
-
|
88
|
+
js: [{
|
89
|
+
source: "./app/assets/javascripts/application.js",
|
90
|
+
target: "./public/assets/javascripts/application.js"
|
91
|
+
}],
|
92
|
+
sass: [{
|
93
|
+
source: "./app/assets/stylesheets/application.scss",
|
94
|
+
target: "./public/assets/stylesheets/application.css"
|
95
|
+
}],
|
96
|
+
static: [{
|
97
|
+
source: "./app/assets/images",
|
98
|
+
target: "./public/assets/images"
|
99
|
+
}],
|
113
100
|
manifest: {
|
114
101
|
file: "./public/assets/manifest.json",
|
102
|
+
key: "short",
|
115
103
|
webRoot: "./public"
|
116
|
-
}
|
104
|
+
},
|
105
|
+
watchDirs: ["./app/assets"]
|
117
106
|
};
|
118
107
|
```
|
119
108
|
|
120
109
|
In this case, your `application.html.erb` would contain lines like these:
|
121
110
|
|
122
111
|
```erb
|
123
|
-
<%= stylesheet_link_tag '
|
124
|
-
<%= javascript_include_tag '
|
112
|
+
<%= stylesheet_link_tag 'application.css', media: 'all', 'data-turbolinks-track': 'reload' %>
|
113
|
+
<%= javascript_include_tag 'application.js', 'data-turbolinks-track': 'reload' %>
|
125
114
|
```
|
126
115
|
|
127
|
-
|
116
|
+
By default this gem assumes that your manifest files can be found in
|
117
|
+
`public/assets/manifest.json`. You can change the path to the manifest
|
118
|
+
file with the following configuration:
|
128
119
|
|
129
120
|
```ruby
|
130
|
-
config.
|
121
|
+
config.faucet_pipeline.manifest_path = Rails.root.join("manifest.json")
|
131
122
|
```
|
132
123
|
|
133
|
-
|
124
|
+
Note that `manifest_path` is an absolute path.
|
125
|
+
|
126
|
+
This gem also provides a Rake task `assets:precompile` that runs faucet with the
|
127
|
+
`--compact --fingerprint` options. It can therefore be used as a drop-in replacement
|
128
|
+
for the task provided by the Rails asset pipeline. It only works if you install
|
129
|
+
your NPM dependencies to the default location (your app's `node_modules` folder).
|
134
130
|
|
135
131
|
## Development
|
136
132
|
|
@@ -5,32 +5,32 @@ module FaucetPipelineRails
|
|
5
5
|
include Singleton
|
6
6
|
|
7
7
|
def fetch(asset_name)
|
8
|
-
|
8
|
+
manifest.fetch(asset_name)
|
9
9
|
rescue KeyError
|
10
10
|
raise "The asset '#{asset_name}' was not in the manifest"
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
+
def manifest
|
16
|
+
return parsed_manifest unless Rails.env.production?
|
17
|
+
@manifest ||= parsed_manifest
|
18
|
+
end
|
19
|
+
|
15
20
|
def parsed_manifest
|
16
21
|
JSON.parse(unparsed_manifest)
|
17
22
|
rescue JSON::ParserError
|
18
|
-
raise "The manifest file '#{
|
23
|
+
raise "The manifest file '#{manifest_path}' is invalid JSON"
|
19
24
|
end
|
20
25
|
|
21
26
|
def unparsed_manifest
|
22
27
|
File.read(manifest_path)
|
23
28
|
rescue Errno::ENOENT
|
24
|
-
raise "The manifest file '#{
|
29
|
+
raise "The manifest file '#{manifest_path}' is missing"
|
25
30
|
end
|
26
31
|
|
27
32
|
def manifest_path
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def relative_manifest_path
|
32
|
-
Rails.configuration.x.faucet_pipeline.manifest_path ||
|
33
|
-
File.join("public", "assets", "manifest.json")
|
33
|
+
Rails.configuration.faucet_pipeline.manifest_path
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -8,5 +8,19 @@ module FaucetPipelineRails
|
|
8
8
|
Manifest.instance.fetch(source)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
initializer "faucet_pipeline.configure_manifest_path" do |app|
|
13
|
+
config.faucet_pipeline = ActiveSupport::OrderedOptions.new
|
14
|
+
config.faucet_pipeline.manifest_path = app.root.join("public", "assets", "manifest.json")
|
15
|
+
end
|
16
|
+
|
17
|
+
rake_tasks do
|
18
|
+
namespace :assets do
|
19
|
+
desc "Compile assets via faucet-pipeline"
|
20
|
+
task :precompile do
|
21
|
+
sh "./node_modules/.bin/faucet --compact --fingerprint"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
11
25
|
end
|
12
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faucet_pipeline_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Dohmen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: 1.3.1
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.6.
|
89
|
+
rubygems_version: 2.6.14
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Use Rails with faucet-pipeline
|