ember-cli-rails-assets 0.7.1 → 0.8.1
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 +26 -7
- data/app/helpers/ember_cli_rails_assets_helper.rb +59 -8
- data/lib/ember_cli/assets/errors.rb +1 -0
- data/lib/ember_cli/assets/paths.rb +9 -0
- data/lib/ember_cli/assets/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f38df79bd5263f5e6d124fd2ddeff3e0f724a6a967e1c165d4799a946f557c51
|
|
4
|
+
data.tar.gz: 36afc4bff115269fa3cb626e5d52aed8f8a8cddfb09b13b8e621602a9b72ec3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '084c574b46d27829d332586bd8e3766ab3e4a1205a373d1c2d1b2a9e2f89e1924393b22b1ed418021e3c30e047ae92357b06c72d89bb5e6b796ec51f7693589c'
|
|
7
|
+
data.tar.gz: 521eee2cc26d824b6e6862b428213cfdd2b1f8bb2827c366d7a0b59688d066818d991a0b9e27065771d1c118a868247a47cf1b301da6cafad1f325c4b0679261
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ actively supported method of serving EmberCLI applications.
|
|
|
12
12
|
However, for the sake of backwards compatibility, `ember-cli-rails-assets`
|
|
13
13
|
supports injecting the EmberCLI-generated assets into an existing Rails layout.
|
|
14
14
|
|
|
15
|
-
[ember-cli-rails]: https://github.com/
|
|
15
|
+
[ember-cli-rails]: https://github.com/tricknotes/ember-cli-rails
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
@@ -33,8 +33,9 @@ $ bundle install
|
|
|
33
33
|
To configure your project to use `ember-cli-rails`, follow the instructions
|
|
34
34
|
listed in the [`ember-cli-rails` README][README].
|
|
35
35
|
|
|
36
|
-
To configure
|
|
37
|
-
|
|
36
|
+
To configure a classic (Broccoli-based) Ember application to use
|
|
37
|
+
`ember-cli-rails-assets`, ensure its `ember-cli-build.js` includes the
|
|
38
|
+
following values:
|
|
38
39
|
|
|
39
40
|
```js
|
|
40
41
|
// frontend/ember-cli-build.js
|
|
@@ -52,7 +53,22 @@ module.exports = function(defaults) {
|
|
|
52
53
|
};
|
|
53
54
|
```
|
|
54
55
|
|
|
55
|
-
[README]: https://github.com/
|
|
56
|
+
[README]: https://github.com/tricknotes/ember-cli-rails#readme
|
|
57
|
+
|
|
58
|
+
### Vite-based applications
|
|
59
|
+
|
|
60
|
+
Vite-based applications (generated with `ember-cli >= 6.8`) require no build
|
|
61
|
+
configuration. For them, use `include_ember_script_tags` on its own: it emits
|
|
62
|
+
everything the application needs to boot — the configuration `<meta>` tag, the
|
|
63
|
+
stylesheet and `modulepreload` links, and the ES module script tags —
|
|
64
|
+
extracted from the generated `index.html`:
|
|
65
|
+
|
|
66
|
+
```erb
|
|
67
|
+
<%= include_ember_script_tags :frontend %>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`include_ember_stylesheet_tags` only supports classic applications, and raises
|
|
71
|
+
an error when called for a Vite-based application.
|
|
56
72
|
|
|
57
73
|
## Mount
|
|
58
74
|
|
|
@@ -126,7 +142,9 @@ path to prepend:
|
|
|
126
142
|
|
|
127
143
|
This project supports:
|
|
128
144
|
|
|
129
|
-
* EmberCLI versions `>= 1.13.13`
|
|
145
|
+
* EmberCLI versions `>= 1.13.13` using the classic (Broccoli-based) build
|
|
146
|
+
* EmberCLI versions `>= 6.8` using the Vite-based build, with
|
|
147
|
+
`include_ember_script_tags` only
|
|
130
148
|
|
|
131
149
|
## Ruby and Rails support
|
|
132
150
|
|
|
@@ -141,7 +159,7 @@ See the [CONTRIBUTING] document.
|
|
|
141
159
|
Thank you, [contributors]!
|
|
142
160
|
|
|
143
161
|
[CONTRIBUTING]: CONTRIBUTING.md
|
|
144
|
-
[contributors]: https://github.com/
|
|
162
|
+
[contributors]: https://github.com/tricknotes/ember-cli-rails-assets/graphs/contributors
|
|
145
163
|
|
|
146
164
|
## License
|
|
147
165
|
|
|
@@ -158,8 +176,9 @@ ember-cli-rails was originally created by
|
|
|
158
176
|
[Jonathan Jackson][rondale-sc].
|
|
159
177
|
|
|
160
178
|
ember-cli-rails-assets was extracted from ember-cli-rails is maintained by
|
|
161
|
-
[Sean Doyle][seanpdoyle].
|
|
179
|
+
[Sean Doyle][seanpdoyle] and [Ryunosuke Sato][tricknotes].
|
|
162
180
|
|
|
163
181
|
[rwz]: https://github.com/rwz
|
|
164
182
|
[rondale-sc]: https://github.com/rondale-sc
|
|
165
183
|
[seanpdoyle]: https://github.com/seanpdoyle
|
|
184
|
+
[tricknotes]: https://github.com/tricknotes
|
|
@@ -1,25 +1,76 @@
|
|
|
1
|
+
require "ember_cli/assets/errors"
|
|
1
2
|
require "ember_cli/assets/lookup"
|
|
3
|
+
require "ember_cli/assets/paths"
|
|
2
4
|
|
|
3
5
|
module EmberCliRailsAssetsHelper
|
|
4
6
|
def include_ember_script_tags(name, prepend: "")
|
|
5
|
-
EmberCli[name]
|
|
7
|
+
app = EmberCli[name]
|
|
8
|
+
app.build
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
paths = EmberCli::Assets::Paths.new(app)
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
if paths.vite?
|
|
13
|
+
vite_ember_script_tags(paths, prepend)
|
|
14
|
+
else
|
|
15
|
+
classic_ember_script_tags(app, prepend)
|
|
16
|
+
end
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
def include_ember_stylesheet_tags(name, prepend: "")
|
|
16
|
-
EmberCli[name]
|
|
20
|
+
app = EmberCli[name]
|
|
21
|
+
app.build
|
|
22
|
+
|
|
23
|
+
paths = EmberCli::Assets::Paths.new(app)
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
if paths.vite?
|
|
26
|
+
raise EmberCli::Assets::NotSupportedError, <<~MSG
|
|
27
|
+
`include_ember_stylesheet_tags` does not support Vite-based
|
|
28
|
+
applications (`ember-cli >= 6.8`).
|
|
29
|
+
|
|
30
|
+
`include_ember_script_tags` already emits their stylesheet tags,
|
|
31
|
+
so remove this call.
|
|
32
|
+
MSG
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
assets = EmberCli::Assets::Lookup.new(app)
|
|
19
36
|
|
|
20
37
|
assets.stylesheet_assets.
|
|
21
38
|
map { |src| [prepend, src].join }.
|
|
22
39
|
map { |src| %{<link rel="stylesheet" href="#{src}">}.html_safe }.
|
|
23
40
|
inject(&:+)
|
|
24
41
|
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# Classic builds ship a fixed set of scripts (vendor and app) resolved
|
|
46
|
+
# through the asset map, so emit a plain script tag per JavaScript asset
|
|
47
|
+
# with `prepend` joined onto each path.
|
|
48
|
+
def classic_ember_script_tags(app, prepend)
|
|
49
|
+
assets = EmberCli::Assets::Lookup.new(app)
|
|
50
|
+
|
|
51
|
+
assets.javascript_assets.
|
|
52
|
+
map { |src| [prepend, src].join }.
|
|
53
|
+
map { |src| %{<script src="#{src}"></script>}.html_safe }.
|
|
54
|
+
inject(&:+)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Vite builds boot from ES modules declared in dist/index.html, so extract
|
|
58
|
+
# the tags required for startup (including the config meta tag and
|
|
59
|
+
# stylesheets) and remap root-absolute paths onto the mount point.
|
|
60
|
+
def vite_ember_script_tags(paths, prepend)
|
|
61
|
+
document = Nokogiri::HTML5(paths.index_html.read)
|
|
62
|
+
prefix = prepend.to_s.chomp("/")
|
|
63
|
+
|
|
64
|
+
tags = document.css(
|
|
65
|
+
'meta[name$="/config/environment"], link[rel="stylesheet"], link[rel="modulepreload"], script'
|
|
66
|
+
).map do |tag|
|
|
67
|
+
%w(href src).each do |attribute|
|
|
68
|
+
value = tag[attribute]
|
|
69
|
+
tag[attribute] = "#{prefix}#{value}" if value&.start_with?("/")
|
|
70
|
+
end
|
|
71
|
+
tag.to_html.html_safe
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
safe_join(tags, "\n")
|
|
75
|
+
end
|
|
25
76
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "nokogiri"
|
|
2
|
+
|
|
1
3
|
module EmberCli
|
|
2
4
|
module Assets
|
|
3
5
|
class Paths
|
|
@@ -21,6 +23,13 @@ module EmberCli
|
|
|
21
23
|
app.dist_path.join("index.html")
|
|
22
24
|
end
|
|
23
25
|
|
|
26
|
+
# Vite builds (ember-cli >= 6.8) boot from ES modules in index.html,
|
|
27
|
+
# while classic builds emit plain script tags.
|
|
28
|
+
def vite?
|
|
29
|
+
index_html.exist? &&
|
|
30
|
+
!Nokogiri::HTML5(index_html.read).at_css('script[type="module"]').nil?
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
protected
|
|
25
34
|
|
|
26
35
|
attr_reader :app
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ember-cli-rails-assets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sean Doyle
|
|
8
|
-
|
|
8
|
+
- Ryunosuke Sato
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -28,6 +28,7 @@ description: Include EmberCLI-generated JavaScript and CSS stylesheet tags in yo
|
|
|
28
28
|
Rails layouts
|
|
29
29
|
email:
|
|
30
30
|
- sean.p.doyle24@gmail.com
|
|
31
|
+
- tricknotes.rs@gmail.com
|
|
31
32
|
executables: []
|
|
32
33
|
extensions: []
|
|
33
34
|
extra_rdoc_files: []
|
|
@@ -43,11 +44,10 @@ files:
|
|
|
43
44
|
- lib/ember_cli/assets/lookup.rb
|
|
44
45
|
- lib/ember_cli/assets/paths.rb
|
|
45
46
|
- lib/ember_cli/assets/version.rb
|
|
46
|
-
homepage: https://github.com/
|
|
47
|
+
homepage: https://github.com/tricknotes/ember-cli-rails-assets
|
|
47
48
|
licenses:
|
|
48
49
|
- MIT
|
|
49
50
|
metadata: {}
|
|
50
|
-
post_install_message:
|
|
51
51
|
rdoc_options: []
|
|
52
52
|
require_paths:
|
|
53
53
|
- lib
|
|
@@ -62,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
63
|
version: '0'
|
|
64
64
|
requirements: []
|
|
65
|
-
rubygems_version:
|
|
66
|
-
signing_key:
|
|
65
|
+
rubygems_version: 4.0.16
|
|
67
66
|
specification_version: 4
|
|
68
67
|
summary: Include EmberCLI-generated JavaScript and CSS stylesheet tags in your Rails
|
|
69
68
|
layouts
|