scalableminds / amd-optimize

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

Maintain Directory Structure #19

Open barefootdeveloper opened 9 years ago

barefootdeveloper commented 9 years ago

It'd be nice if it were possible for the tool to output files in the source directory structure.

For example I have

app | Controllers | + Controller1.js | Directives | + CustomDirective.js | app.js

whenever I run them through the tool I get

Controller1.js CustomDirective.js app.js

I have a fairly large project and when navigating through the files outputted by the source map it'd be nice if that directory structure was preserved. I'm new to gulp so I'm afraid I don't know if this is possible or not.

normanrz commented 9 years ago

Hi. Just added a test for your scenario and it seems to be working quite well in my case. Can you provide a specific code sample?

barefootdeveloper commented 9 years ago

Okay I think I created a sample project that should demonstrate it for you.

https://www.dropbox.com/s/64zcdy6l8zpvqdj/angular-requirejs-seed-master.zip?dl=0

It's possible I'm just doing something irregular.

If you comment out the concat and uglify plugins you'll see that it flattens the directory structure. Obviously doing that will prevent the files from actually running.

normanrz commented 9 years ago

Can you try the base option in gulp.src?

gulp.src("app/js/**/*.js", { base: "." })
barefootdeveloper commented 9 years ago

Looks like that solved the majority of it for me, there's still some instances where it's pulling anything passed into the paths out into the root directory, but I should be able to manage that.

Thank you.