dowjones / gulp-bundle-assets

Create static asset (js, css) bundles from a config file: a common interface to combining, minifying, revisioning and more
MIT License
133 stars 36 forks source link

Searching multiple base paths for assets #91

Open alexweissman opened 8 years ago

alexweissman commented 8 years ago

I want to be able to search multiple base paths for assets referenced in my bundle.config.json file. For example, I have assets split up between app/core/assets/ and a set of subdirectories defined as app/sprinkles/*/assets/. I tried setting my base option as:

base: '../app/{core/assets/,sprinkles/*/assets/}';

This is the syntax specified in the npm glob module.

gulp-bundle-assets seems to recognize the curly-brace syntax, but it doesn't seem to construct the paths to my assets correctly. For example, I have this in my bundle.config.json:

{
  "bundle": {
    "js/main": {
        "scripts": [
            "vendor/bootstrap-3.3.6/js/bootstrap.js",
            "vendor/jQueryValidation-1.14.0/jquery.validate.js",
            "vendor/jQueryValidation-1.14.0/additional-methods.js"
        ]

When I run my build task, I get output like this:

Bundle 'js/main.scripts' using ../../../../../../core/assets/vendor/bootstrap-3.3.6/js/bootstrap.js

So, for some reason it is losing the app/, and instead trying to move way back up the directory tree.

alexweissman commented 8 years ago

ping!

chmontgomery commented 8 years ago

sorry @alexweissman I just changed jobs so I've had little time to manage gba. Unfortunately this usage isn't something I've personally ever tried or heard of anyone trying.

The base prefixed to the script paths using path.join and then passed to gulp here: https://github.com/dowjones/gulp-bundle-assets/blob/master/lib/stream-files.js#L48

gulp, I think, using this module internally to understand the path: https://github.com/contra/glob2base

I likely won't have time to look more into this but if you fix it via a PR I will merge it!

alexweissman commented 8 years ago

Thanks for getting back to me - and I completely understand.

I don't really have much experience with Node and Gulp, so we might have to wait until someone who does comes along!

Eduardo-Julio commented 4 years ago
            scripts: [
                bf.buildJSPath("user/register/controllers/proSignupJobsController.js"),
                bf.buildJSPath("shared/directives/tpCarousel.js"),
            ],

We use functions to build different paths based on custom logic, works perfectly with environment variables or any other stuff.