Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Example of configFile import #54

Open
beenanner opened this issue Jul 16, 2015 · 3 comments
Open

Example of configFile import #54

beenanner opened this issue Jul 16, 2015 · 3 comments

Comments

@beenanner
Copy link

I'm not sure what I'm doing wrong as the documentation doesn't actually show a good example of using a config file. When running the following

gulp.task('amdoptimize', function() {
    amdOptimize.src("main.default", {
        configFile : "./configs/amd.json",
        baseUrl : "./js",
        dir:"./js/build"
    })
    .pipe(concat("main.default.js"))
    .pipe(gulp.dest("js/build"));
});

I get the following error. :'(

[16:58:23] Finished 'amdoptimize' after 11 ms
Error: No file for module 'jquery' found.
...

Here is my amd.json file.

({
    "paths": {
        "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min"
    },
    "map": {
        "*": {
            "facebook": "//connect.facebook.net/en_US/all.js",
            "facebook-debug": "//connect.facebook.net/en_US/all/debug.js"
        }
    },
    "config": {
        "version": {
            "libs/jquery/lazyload": "1.9.3",
            "libs/jquery/mobile": "1.4.0a1",
            "libs/jquery/numberformatter": "1.2.3",
            "libs/jquery/placeholder": "0.2.4",
            "libs/jquery/scrollbar": "0.2.4.custom",
            "libs/jquery/tablesorter": "2.0.5",
            "libs/jquery/wysibb": "1.5.1",
            "libs/jquery/ui/jquery.ui.core": "1.9.2",
            "libs/jquery/ui/jquery.ui.draggable": "1.9.2",
            "libs/jquery/ui/jquery.ui.mouse": "1.9.2",
            "libs/jquery/ui/jquery.ui.position": "1.9.2",
            "libs/jquery/ui/jquery.ui.slider": "1.9.2",
            "libs/jquery/ui/jquery.ui.touch-punch": "0.2.2"
        }
    }
})

Any idea what I'm doing wrong?

@beenanner beenanner reopened this Jul 16, 2015
@normanrz
Copy link
Member

There is no support for remote scripts yet. That's why it can't find jquery at runtime.

@beenanner
Copy link
Author

Thanks for the quick reply @normanrz so if I wanted to load a path relatively it seems the inline configs vs an external configFile are different? It seems to work if I inline the configs but I don't think that would be very DRY if I wanted to create a task for each page in my app. :-)

Loading inline this works.

"paths": {
        "jquery": "../../js/libs/jquery-1.8.3",
    },

If I drop that in a config file I get the previous error mentioned.

Error: No file for module 'jquery' found.

Seems the module.exports.loader is getting the wrong path when using the config file. It's as if it ignores the paths setup and just looks in the basePath. I'm still trying to track down the original code that sets that and I could possible submit a patch if you don't figure it out first. :-p

@beenanner
Copy link
Author

I was able to work around the configFile issue for now by moving the paths to be inline with the gulp task before loading the configFile.

Current setup
gulpfile.js

gulp.task('amdoptimize', function() {
    amdOptimize.src("main.default", {
        "paths": {
              "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min"
        },
        configFile : "./configs/amd.json",
        baseUrl : "./js",
        dir:"./js/build"
    })
    .pipe(concat("main.default.js"))
    .pipe(gulp.dest("js/build"));
});

amd.json file

({
    "map": {
        "*": {
            "facebook": "//connect.facebook.net/en_US/all.js",
            "facebook-debug": "//connect.facebook.net/en_US/all/debug.js"
        }
    },
    "config": {
        "version": {
            "libs/jquery/lazyload": "1.9.3",
            "libs/jquery/mobile": "1.4.0a1",
            "libs/jquery/numberformatter": "1.2.3",
            "libs/jquery/placeholder": "0.2.4",
            "libs/jquery/scrollbar": "0.2.4.custom",
            "libs/jquery/tablesorter": "2.0.5",
            "libs/jquery/wysibb": "1.5.1",
            "libs/jquery/ui/jquery.ui.core": "1.9.2",
            "libs/jquery/ui/jquery.ui.draggable": "1.9.2",
            "libs/jquery/ui/jquery.ui.mouse": "1.9.2",
            "libs/jquery/ui/jquery.ui.position": "1.9.2",
            "libs/jquery/ui/jquery.ui.slider": "1.9.2",
            "libs/jquery/ui/jquery.ui.touch-punch": "0.2.2"
        }
    }
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants