moshen / jekyll-asset_bundler

A small plugin for Jekyll to easily bundle and compress site assets
MIT License
101 stars 21 forks source link

Doesn't work? #1

Closed kenany closed 12 years ago

kenany commented 12 years ago

I know it's still in Alpha, but it doesn't seem to work on my end.

I left the config alone but disabled minification because yui-compressor doesn't work on Windows. I also commented out everything YUI-related in asset_bundler.rb.

In my source/_includes folder, I have a HTML file with this in it:

{% bundle [/js/plugins.js, /js/script.js] %}

Whether in dev mode or not, nothing bundles when I run jekyll. In dev mode, that part of the generate page is left blank.

moshen commented 12 years ago

Do you find any error messages in your destination files where the markup should be?

You could safely remove lines: 4, 139 and 165 to 175. If that isn't what you have already done.

What YAML engine are you using? Have you tried putting your script paths in quotes?

kenany commented 12 years ago

No error messages, space is left blank.

I didn't have 139 commented out, but commenting it out didn't help.

Neither single nor double quotes work. I'm not sure what YAML engine I'm using, but I neglected to mention that I'm using Ruby 1.9.2

moshen commented 12 years ago

It's probably not related to the yui-compressor gem. It's probably Windows specific. I'll test it out tomorrow.

moshen commented 12 years ago

I could not replicate the issue using Ruby 1.9.2 on Windows. Do you have other plugins in your _plugins directory?

kenany commented 12 years ago

Quite a few, pretty much all the one's here (in that specific commit). Besides those, I also have tweet-tag.

moshen commented 12 years ago

I downloaded octopress and tried it with asset_bundler and it seemed to work perfectly.

Are you sure that you are using the correct paths for your asset files? Remember the path is relative to the 'source' directory.

Doing:

{% bundle [/javascripts/ender.js, /javascripts/github.js] %}

worked with octopress. These files are in source\javascripts in the octopress root folder.

kenany commented 12 years ago

Everything is relative to the source directory. I've renamed javascripts/ to js/. Within that folder, there are in fact two js files: plugins.js and script.js (I've moved the files that previously resided there to a different location, but they're not what I'm bundling).

moshen commented 12 years ago

I made a couple of tweaks and added an error message to this version of asset_bundler.rb, let me know if you see any errors.

kenany commented 12 years ago

I get this error (it's spit out many times because it's for each webpage):

Building site: source -> _site
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Asset Bundler Error - File: source/js/plugins.js not found, ignoring...
Asset Bundler Error - File: source/js/script.js not found, ignoring...
Successfully generated site: source -> _site

Yet the files are actually there.

moshen commented 12 years ago

I figured it out. It is a bug. Basically I reference the source folder setting in the Jekyll configuration, which in your case is a folder named source. The problem is when the _includes are included, Jekyll changes the PWD to the _includes folder.

When Asset Bundler looks for the files in source\js\script.js, it resolves the path to _includes\source\js\script.js, which is obviously wrong.

I will have a fix uploaded shortly ( which also doesn't default to the yui-compressor gem ).

kenany commented 12 years ago

Great to know, but why didn't it happen to your copy of Octopress?

moshen commented 12 years ago

Probably because I didn't test using the _includes feature. This is a problem that only seems to be encountered when using an include AND explicitly setting a source directory. My fault for not being thorough enough the first time through.

kenany commented 12 years ago

Ok, I can confirm that it works like this:

{% bundle [../../js/plugins.js, ../../js/script.js] %}

(obviously until you upload the fix)

kenany commented 12 years ago

Oh, I assumed you tried it in _includes/after_footer.html like I had.

moshen commented 12 years ago

Heh, I did... In a vanilla Jekyll repo. I didn't copy the same stuff into the test Octopress repo I made. When I saw your error messages I looked back at my Octopress repo and realized my mistake.

Anyway, this is fixed in 30915730a51b4fad4eb3f1b9667de4c552ef75c0

I will be adding more features shortly :smiley: