gulp-requirejs-optimize icon indicating copy to clipboard operation
gulp-requirejs-optimize copied to clipboard

build not recognizing paths correctly

Open mix3d opened this issue 8 years ago • 1 comments

I could be setting this up wrong, but here is my issue:

I am noticing in the error log that it is looking for a file that doesn't exist. Error: Error: ENOENT: no such file or directory, open 'path/to/project/assets/js/marionette.js'

In my main.js, I have Marionnette defined as such:

require.config({
    baseURL:'assets/js',
    paths:{
        ...
        marionette  : "vendor/backbone.marionette",
        ...
   }
   shim: {
        ...
        backbone: {
            deps: ['jquery', 'underscore'],
            exports: 'Backbone',
        },
        marionette: {
            deps: ['backbone'],
            exports: 'Marionette',
        },
        ...
    }
});

I looks like the plugin is skipping the config completely (the file should be backbone.marionette.js), since it is not looking in the /vendor/ folder nor is it looking for the right file name.

Here is my simple gulp task:

gulp.task('rqs', function () {
  return gulp.src('assets/js/main.js')
    .pipe(requirejsOptimize(function (file) {
      return {
        siteRoot: '../../',
      };
    }))
  .pipe(gulp.dest('dist'));
});

Am I doing something wrong? Thanks!

mix3d avatar Mar 24 '17 19:03 mix3d

Looks like the issue is that the optimizer isn't getting sent the mainConfigFile parameter that points to your main.js file with the paths config in it. Without that parameter, the optimizer doesn't read the config from the file it's processing, it just uses whatever config you pass to the plugin. Right now, that's just your siteRoot config. I think the task should look something like this:

gulp.task('rqs', function () {
  return gulp.src('assets/js/main.js')
    .pipe(requirejsOptimize({
      mainConfigFile: 'assets/js/main.js'
    }))
  .pipe(gulp.dest('dist'));
});

jlouns avatar Mar 26 '17 22:03 jlouns