1

I have around 50 JS files and I have to optimize it using r.js and node... I dont want to specify all the JS files, instead specify the top level folder and somehow let r.js to get all the required js files....

Is there a way to achieve this? Currently I am specifying all the 50 js files in a common js files and referring it in my build.js...I have more files in the coming weeks, and so maintaining a common js file will be a pain.

Please suggest some steps.

here is my build file

({   
    baseUrl: ".",
    mainConfigFile: "../App/main.js",
    //modules: [
    //   //{ name: "../App/Crosspoint/Address/AddressList" }
    //   { name: "../App/Crosspoint/Office/OfficeDetails" }
    //],
    //paths: {
    //    app: '../App',
    //    jquery: 'jquery'
    //},
    name: "../App/Crosspoint/Office/OfficeDetails",
    deps: ["../App"],
    out: "main-built123.js",
    rawText: {
        'some/id': 'define(["another/id"], function () {});'
    },
   // dir: "app",    
})
2
  • Can you post the snippet similar to what you have in the "Common JS" file with the reference to the 50 different files? Apr 27, 2013 at 4:13
  • the common file which I had referred is the config file where we maintain all the script references..say there is a folder A which had B.js, then in the file we will have require(B). (again relative path). I am just thinking to say it in folder level and let r.js scan through the folder to get all the associated script files. Apr 27, 2013 at 12:32

1 Answer 1

1

Optimizer should include all the dependencies required by main config file. Also if you have nested dependencies then specify:

findNestedDependencies: true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.