basset icon indicating copy to clipboard operation
basset copied to clipboard

Duplicate assets in collection

Open radmen opened this issue 11 years ago • 5 comments

In app/assets/javascripts I have a bunch of JS files. I'd like to make one of them (jquery.js) to be the first in collection.

I decided to do something like this:

$collection->add('../app/assets/javascripts/jquery.js');
$collection->directory('../app/assets/javascripts', function($c) {
  $c->requireDirectory();
});

On the output I have duplicate jquery entry. It's because it was included in collection twice. IMO it would be great if Basset could somehow detect duplicates and skip them.

Possibly my problem is because I can't easily order my assets.

radmen avatar May 17 '13 09:05 radmen

I have a feeling this too may be related to assets being outside of public. I can't recreate this.


If that's the case I might have it log an error of some description when trying to navigate outside of public. It's just too much of a hassle. I'll look into some possible solutions.

jasonlewis avatar May 17 '13 09:05 jasonlewis

I have a feeling this too may be related to assets being outside of public. I can't recreate this.

Ok, I'll try to move my assets to public and then give feedback.

radmen avatar May 17 '13 09:05 radmen

Moving assets to public fixed the problem.

radmen avatar May 17 '13 10:05 radmen

Cool thanks @radmen. I know it's possible. But from now on I'm going to push for people to keep them in public. It's easier for everyone involved. :smile:

jasonlewis avatar May 17 '13 10:05 jasonlewis

Once again I'm reopening this issue :)

This time I have some more details, so let's start from them.

// app/config/packages/jasonlewis/basset/config.php
'application' => function($collection)
        {
            $directory = $collection->directory('assets/stylesheets', function($collection)
            {
                $collection->add('bootstrap.css');
                $collection->add('style.css');
                $collection->add('rwd.css');

                $collection->requireDirectory('less')->apply('Less');
                $collection->requireDirectory('sass')->apply('Sass');
                $collection->requireDirectory();

                dd($collection);
            });
        }

Output (fragment) of dd():

protected 'assets' => 
    object(Illuminate\Support\Collection)[179]
      protected 'items' => 
        array (size=7)
          'W:\xxx\public/assets\stylesheets/bootstrap.css' => 
            object(Basset\Asset)[182]
              ...
          'W:\xxx\public/assets\stylesheets/style.css' => 
            object(Basset\Asset)[184]
              ...
          'W:\xxx\public/assets\stylesheets/rwd.css' => 
            object(Basset\Asset)[186]
              ...
          'W:\xxx\public/assets\stylesheets\bootstrap.css' => 
            object(Basset\Asset)[205]
              ...
          'W:\xxx\public/assets\stylesheets\jqcloud.css' => 
            object(Basset\Asset)[206]
              ...
          'W:\xxx\public/assets\stylesheets\rwd.css' => 
            object(Basset\Asset)[210]
              ...
          'W:\xxx\public/assets\stylesheets\style.css' => 
            object(Basset\Asset)[212]
              ...

As you can see same assets where added to collection. It happens only on Windows, so probably it's something related with DIRECTORY_SEPARATOR.

radmen avatar Jun 19 '13 12:06 radmen