octopress / asset-pipeline

Adds your local CSS, Sass, Javascript and Coffeescript files to Octopress Ink's asset pipeline.
MIT License
4 stars 3 forks source link

Asset pipeline ignores files? #7

Closed drallgood closed 9 years ago

drallgood commented 9 years ago

Hi. I've got a very weird issue. Some of my JS files aren't included in the generated file. I managed to track this down to the point that they aren't even included in the array returned by Octopress.site.static_files Other files in the same directory work fine.

Any ideas why that is?

drallgood commented 9 years ago

Update: I was wrong thinking they weren't included in the static_files array. There's something weird going on.

If you modify the file octopress-asset-pipeline.rb like this:

      def add_js
        Octopress.site.static_files.each do |f| 
          puts "pathJ0: '#{f.path}'"
         end
        Octopress.site.static_files.each do |f| 
          puts "pathJ1: #{f.path}"
          if f.path =~ /\.js$/ 
            puts "   match"
            @js << Javascript.new(self, f)
            Octopress.site.static_files.delete(f) if combine_js
          else
            puts "  NO match"
          end
        end
        Octopress.site.static_files.each do |f| 
          puts "pathJ2: '#{f.path}'"
        end
      end

you get:

...
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/github.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/jquery.ad-gallery.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/jquery.fancybox.pack.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/jquery.lazyyoutube.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/modernizr.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/octopress.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/pinboard.js'
pathJ0: '/Users/patrice/git/brendamour.net/source/javascripts/twitter.js'
...
pathJ1: /Users/patrice/git/brendamour.net/source/javascripts/github.js
   match
pathJ1: /Users/patrice/git/brendamour.net/source/javascripts/jquery.fancybox.pack.js
   match
pathJ1: /Users/patrice/git/brendamour.net/source/javascripts/modernizr.js
   match
pathJ1: /Users/patrice/git/brendamour.net/source/javascripts/pinboard.js
   match
...
pathJ2: '/Users/patrice/git/brendamour.net/source/javascripts/jquery.ad-gallery.js'
pathJ2: '/Users/patrice/git/brendamour.net/source/javascripts/jquery.lazyyoutube.js'
pathJ2: '/Users/patrice/git/brendamour.net/source/javascripts/octopress.js'
pathJ2: '/Users/patrice/git/brendamour.net/source/javascripts/twitter.js'
...

I think, this happens because you manipulate the array while iterating over it. Cloning it indeed fixes this issue.

imathis commented 9 years ago

Hmm. I'll have a look. Thanks for posting the issue!

imathis commented 9 years ago

Thanks so much for filing this issue. It should be fixed in 1.1.5 which I've just released.