imathis / esvg Goto Github PK
View Code? Open in Web Editor NEWA tool for embedding svg icons in Rails or stand-alone apps.
License: MIT License
A tool for embedding svg icons in Rails or stand-alone apps.
License: MIT License
We're using Rails 5.1 and have added the gem as per your instructions in the README. Our config/initializers/assets.rb
is as follows
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w( jquery-3.2.1.min.js )
Esvg.precompile_assets
Note, the Esvg line is included and at the bottom of the file.
When we run rails assets:precompile
in a production environment (Heroku), the svgs-[fingerprint].js is not being created and thus our app is not starting.
Update
It seems that the precompile step is writing the svgs.js file to the wrong location and therefore the helper can't load it in the request
remote: Writing /tmp/build_f4d647447c24e85e80b791e7f03deed4/public/javascripts/svgs-91d4da5be527e637db9f8aadd1d09cc2.js
remote: Writing /tmp/build_f4d647447c24e85e80b791e7f03deed4/public/javascripts/svgs-91d4da5be527e637db9f8aadd1d09cc2.js.gz
Great project, thank you for creating this!
I'm trying to add the asset precompile support to my Rails 5.2.4.3 with this initializer:
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
# Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += []
Esvg.precompile_assets
This results in an error though:
Traceback (most recent call last):
72: from bin/rails:4:in `<main>'
71: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require'
70: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency'
69: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `block in require'
68: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
67: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
66: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
65: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
64: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
63: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands.rb:18:in `<main>'
62: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/command.rb:46:in `invoke'
61: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/command/base.rb:69:in `perform'
60: from /home/XXX/.gem/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
59: from /home/XXX/.gem/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
58: from /home/XXX/.gem/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
57: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:142:in `perform'
56: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:142:in `tap'
55: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:147:in `block in perform'
54: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:51:in `start'
53: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
52: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
51: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/commands/server/server_command.rb:27:in `app'
50: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
49: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
48: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
47: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
46: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
45: from /home/XXX/.gem/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
44: from config.ru:23:in `block in <main>'
43: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require'
42: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency'
41: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `block in require'
40: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
39: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
38: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
37: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
36: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
35: from /home/XXX/Source/YYY/config/environment.rb:5:in `<main>'
34: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/application.rb:361:in `initialize!'
33: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:60:in `run_initializers'
32: from /usr/share/ruby/tsort.rb:205:in `tsort_each'
31: from /usr/share/ruby/tsort.rb:226:in `tsort_each'
30: from /usr/share/ruby/tsort.rb:347:in `each_strongly_connected_component'
29: from /usr/share/ruby/tsort.rb:347:in `call'
28: from /usr/share/ruby/tsort.rb:347:in `each'
27: from /usr/share/ruby/tsort.rb:349:in `block in each_strongly_connected_component'
26: from /usr/share/ruby/tsort.rb:415:in `each_strongly_connected_component_from'
25: from /usr/share/ruby/tsort.rb:415:in `call'
24: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:50:in `tsort_each_child'
23: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:50:in `each'
22: from /usr/share/ruby/tsort.rb:421:in `block in each_strongly_connected_component_from'
21: from /usr/share/ruby/tsort.rb:431:in `each_strongly_connected_component_from'
20: from /usr/share/ruby/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
19: from /usr/share/ruby/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
18: from /usr/share/ruby/tsort.rb:228:in `block in tsort_each'
17: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:61:in `block in run_initializers'
16: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:32:in `run'
15: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/initializable.rb:32:in `instance_exec'
14: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/engine.rb:619:in `block in <class:Engine>'
13: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/engine.rb:619:in `each'
12: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
11: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/engine.rb:662:in `load_config_initializer'
10: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/notifications.rb:170:in `instrument'
9: from /home/XXX/.gem/gems/railties-5.2.4.3/lib/rails/engine.rb:663:in `block in load_config_initializer'
8: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:285:in `load'
7: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency'
6: from /home/XXX/.gem/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:285:in `block in load'
5: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
4: from /home/XXX/.gem/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
3: from /home/XXX/Source/YYY/config/initializers/assets.rb:23:in `<main>'
2: from /home/XXX/.gem/gems/esvg-4.6.11/lib/esvg.rb:124:in `precompile_assets'
1: from /home/XXX/.gem/gems/rake-13.0.1/lib/rake/task.rb:405:in `[]'
/home/XXX/.gem/gems/rake-13.0.1/lib/rake/task_manager.rb:59:in `[]': Don't know how to build task 'assets:precompile' (See the list of available tasks with `rake --tasks`) (RuntimeError)
It looks like the initializer is running before Rails tasks are fully loaded. Is there something wrong in my project?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.