mintdigital / asset_hat Goto Github PK
View Code? Open in Web Editor NEWLoad CSS and JS faster in Rails. Your assets are covered.
Home Page: http://mintdigital.github.com/asset_hat/
License: MIT License
Load CSS and JS faster in Rails. Your assets are covered.
Home Page: http://mintdigital.github.com/asset_hat/
License: MIT License
When running the asset_hat:config task, I'm getting "No such file or directory" errors. The path in the error is similar to:
/[ path to app root ]/[ path to app root AGAIN ]/config/assets.yml
Looking around, I found that AssetHat::CONFIG_FILEPATH is defined to be the absolute path to the config file in RAILS_ROOT:
CONFIG_FILEPATH = File.join(RAILS_ROOT, 'config', 'assets.yml')
But then, in asset_hat/tasks.rb (asset_hat:config), the target file path is defined as RAILS_ROOT joined with AssetHat::CONFIG_FILEPATH. Thus the RAILS_ROOT is being appended twice:
target_filepath = File.join(RAILS_ROOT, AssetHat::CONFIG_FILEPATH)
Anyone got this working with Rails 2.2.2 ?
I get unitialized constant Rails::Plugin::AssetHatHelper
uninitialized constant Rails::Plugin::AssetHatHelper
/Users/barmstrong/NetBeansProjects/viper/vendor/rails/activesupport/lib/active_support/dependencies.rb:102:in `const_missing'
/Users/barmstrong/NetBeansProjects/viper/vendor/gems/asset_hat-0.3.0/rails/init.rb:1:in `evaluate_init_rb'
I have an application that has some javascripts but no css files (at all). This causes rake asset_hat:minify to abort, since it requires at least one css package.
I'm aware that this use case is very unusual, however a nicer way to handle this situation other than create an empty css file would be appreciated :)
AssetHat should check for local copies of vendor JS in public/javascripts/vendors/
by default, then public/javascripts/vendor/
, then public/javascripts/
. For consistency, similar ought to be done with CSS; some third-party JS ships with stylesheets.
it would make developer's life much easier whenever we're forced to do some quick live tests on the assets..
how about a headjs loader?
Getting the following deprecation warnings, should be an easy fix. I can submit a pull request if you want. Let me know.
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/css.rb:5:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/css.rb:21:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/css.rb:43:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/css.rb:68:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/css.rb:158:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/js.rb:5:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/js.rb:34:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks/js.rb:107:in `block (2 levels) in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/deploy/shared/bundle/ruby/1.9.1/gems/asset_hat-0.4.1/lib/asset_hat/tasks.rb:7:in `block in <top (required)>'
Anyone using AH with Rails 2.1?
Thanks,
Wes
Adding asset hosts within stylesheets is currently only supported for URLs beginning with /images/
, but assets.yml
should allow configuring this for other paths, e.g., /videos/
.
All the .js or .min.js (bundle) files returned by AH appear to come back with the MIME-type of application/javascript.
My Apache configuration is currently not set up to compress these types of files.
Is application/javascript a preferred or more standards-compliant MIME-type for Javascript than text/javascript or application/x-javascript?
If so, is there any harm in me adding application/javascript to the list of MIME types available for compression by Apache? I can't imagine there would be since all of the other JS MIME types are in there, but I thought I would ask.
Many thanks.
Is there any intention to add mercurial support?
If not; how would I use the intrinsic file timestamps, like rails does for image files, within css files?
Progress: https://github.com/mintdigital/asset_hat/tree/vendor-refactor
The idea is to allow per-vendor methods, such as local_fallback
.
This is blocking us from adding more useful cdnjs vendors, such as xuijs and json2.
From this Twitter thread: https://twitter.com/jcoglan/status/102459518188920833
If neither include_css
nor include_js
are being used to load bundles yet, AssetHat should at most log a warning if assets.yml
is missing or has no bundles.
If include_css
or include_js
are being used to load bundles, and assets.yml
is missing or has no bundles, AssetHat should raise an error.
Currently, cache busting is managed by adding a bundle's latest Git SHA to the query string. Two problems:
Change from application.min.css?a1b2c3
to application-a1b2c3.min.css
(like in Rails 3.1), and drop Git SHAs in favor of MD5 fingerprints.
There needs to be some standard symbolizing or stringifying in AssetHat. If you want to pull jquery or prototype from the Google CDN, you must use symbols (:jquery, :prototype) to specify them. In addition, it appears that you must use strings for non-vendor JS that you are pulling in.
Not sure if this applies to bundle names or not. But it's confusing that there are two different ways that you have to specify libraries in the include_js call.
To keep the AssetHat gem lightweight, this should not just add gem dependencies for various other minifiers -- this would make installation very slow.
As we chatted about, the setup process in a host app should instead be:
Gemfile
to include your minifier of choice.assets.yml
to use the AssetHat engine for that minifier.In this way, an "AssetHat engine" is essentially an adapter -- it provides a universal interface for using any minifier. AssetHat would contain a bunch of engines out of the box, and to use one, just add the corresponding minifier to your Gemfile
.
Out of the box, AssetHat should still support weak
and cssmin
for CSS, and weak
and jsmin
for JS. These are lightweight, pure Ruby, and have few/no other dependencies.
Asset Hat should us https:// urls for hosted Javascript when we're serving the page over https.
Otherwise browser complains about non-secure elements. Not sure if all external resources that are means to be used by asset hat have https version, but I'm sure google stuff does
Hi,
Thanks for making it an opensource gem.
Just wanted to check if you guys had any experience in using this gem in heroku?
If not I might actually test it and check if its compatible with heroku infrastructure (no write access on the server).
Thanks,
Ajay
Is this a mistake?
"By default, vendor JS will load from Google's CDN in production (or any environment where config.action_controller.consider_all_requests_local is set to true)"
Shouldn't that be "false" instead of "true"?
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.