shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.39k stars 122 forks source link

One output file for each gulp.src file (multiple outputs) #219

Closed sixclones closed 4 years ago

sixclones commented 4 years ago

Hello,

It seams that webpack-stream can't generate a different file for each source file. What I want is to have entries points defined by gulp.src('**/*.js') and for each of those files having an outputed file.

project
|__js
   |__main.js
   |__card.js
   |__button.js
|__build
   |__main.min.js
   |__card.min.js
   |__button.min.js
const task = () => {
  return gulp.src('js/*.js')
    .pipe(webpack())
    .pipe(gulp.dest('build/'))
};

Currently webpack-stream generated only one script. So my question is: does webpack-stream can handle this?

Thx

jbfraser1 commented 4 years ago

It can generate multiple output files with the vinyl-named package.

I think a call similar to this should work for you.

const named = require('vinyl-named');
...
const task = () => {
  return gulp.src('js/*.js')
    .pipe(named())  
    .pipe(webpack())
    .pipe(gulp.dest('build/'))
};
sixclones commented 4 years ago

Yep I figured out this later and forgot to close the issue.