MattCheely / requirejs-maven-plugin

Maven plugin for RequireJS optimization
GNU Lesser General Public License v2.1
66 stars 21 forks source link

dir configuration is not clear from README #23

Open alanrubin opened 11 years ago

alanrubin commented 11 years ago

I have created a json config file as described at http://requirejs.org/docs/optimization.html#wholeproject but it is not clear what should be set as "dir" property.

Maybe you should add a sample directory structure and a sample config file to README ?

alanrubin commented 11 years ago

To be clear, my js files are located inside /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal/war/src/main/webapp/js (main is located at /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal/war/src/main/webapp/js/main.js) , I'm using version 1.1.0 and I'm struggling to make the configuration file work. I'm getting error:

[DEBUG] filtering /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal/war/src/main/config/app.build.js to /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal/war/target/requirejs-config/filtered-build.js
Error: Error: ERROR: module path does not exist: /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal/war/target/js/main.js for module named: main. Path is relative to: /Users/alanrubin/Developer/kt/A/PortalSDD/a-portal

My configuration file is

({
    appDir : '../',
    baseUrl : 'js',
    dir : '../main/webapp',
    paths: {
        jquery: 'libs/jquery/jquery-1.8.3.min', // jQuery
        jqueryui: 'libs/jqueryui/jquery-ui-1.9.2.custom', // jQuery
        'jquery.blockUI': 'libs/jquery/jquery.blockUI', // jQuery BlockUI plugin
        moment: 'libs/momentjs/moment', // Moment js - Date JS library
        underscore: 'libs/underscorejs/underscore-min', // Underscore.js minified
        backbone: 'libs/backbonejs/backbone', // Backbone.js minified
        'backbone-pageable': 'libs/backbone-pageable/backbone-pageable',
        // paginator: , // Paginator plugin for paginating collections in Backbone.js
        levenshtein: 'libs/backbonejs/levenshtein', // Levenshtein algorithm for string comparison in paginator
        text: 'libs/requirejs/text',
        modelbinder: 'libs/backbonejs/Backbone.ModelBinder' // Binding models and views
    },
    optimize: 'uglify',
    modules: [
        {
            name: 'main'
        }
    ]
})

Any clues ?

MattCheely commented 11 years ago

The config file format you're trying to sort out is from the requirejs project. I don't document it, because I don't maintain it's behavior. You can find documentation at: requirejs.org

That said, it looks like you've turned on config filtering when building. I believe it's called out in the README, but if you do that, you need to use absolute paths for dir & appDir. Normally those would be relative to the location of your config file, but the filtering process makes a temporary copy of the config in a new location, so the relative paths will no longer work. It doesn't look like filtering is doing anything for you with that configuration, so I'd recommend just disabling it and seeing if that fixes your problem.