scalableminds / amd-optimize

An AMD (RequireJS) optimizer that's stream-friendly. Made for gulp.
MIT License
162 stars 29 forks source link

Error: No file for module 'static/modules/myModule/moduleEntry' found. #72

Closed varlinor closed 8 years ago

varlinor commented 8 years ago

I have an js file in another directory, but my project need to import this file, structure is following: -webapp require.config.js static/modules/myModule/ moduleEntry.js dependencyA.js dependencyB.js ...... static/app/extend/widgetsDefine.js

and gulp script is like this:

gulp.task('build', function () { gulp.src([ 'static/app/extend/widgetsDefine.js', 'static/modules/myModule/.js', '!static/modules/myModule/.min.js'],{base:'static/modules/myModule/'}) .pipe(amdOptimize("static/modules/myModule/moduleEntry", { baseUrl:'static/modules/myModule/', configFile:'main.js', exclude:[ 'static/modules/otherModules/moduleC', 'static/app/extend/widgetsDefine.js' ], findNestedDependencies:false })) .pipe(concat("moduleEntry-concat.js")) .pipe(gulp.dest("static/modules/myModule")) .pipe(rename("moduleEntry-concat.min.js")) .pipe(uglify()) .pipe(gulp.dest("static/modules/myModule")); });

then amd-optimize catch an error: Error: No file for module 'static/modules/myModule/moduleEntry' found.

so , How can I import a js file form a different directory?

waiting for answer sincerely

combine with issue comment at 23#issuecomment-237820420

varlinor commented 8 years ago

after several try, I found change 'baseUrl' to '.' , at same time , change configuration of gulp.src 'base' to 'static' , the plugin works rightly. the final script is following:

gulp.task('build', function () { gulp.src([ 'static/app/extend/widgetsDefine.js', 'static/modules/myModule/!.js', '!static/modules/myModule/!.min.js'],{base:'static'}) .pipe(amdOptimize("static/modules/myModule/moduleEntry", { baseUrl:'.', configFile:'main.js', exclude:[ 'static/modules/otherModules/moduleC', 'static/app/extend/widgetsDefine.js' ], findNestedDependencies:false })) .pipe(concat("moduleEntry-concat.js")) .pipe(gulp.dest("static/modules/myModule")) .pipe(rename("moduleEntry-concat.min.js")) .pipe(uglify()) .pipe(gulp.dest("static/modules/myModule")); });