Olena Horal
Olena Horal

Reputation: 1214

gulp src vs webpack entry

I have the following simple webpack config:

module.exports = {
    entry: "entry.js",
    failOnError: true,
    devtool: "source-map",
    output: {
        filename: "bundle.js",
        sourceMapFilename: "souce-map.js"
    },
    resolve: {
        root: ["./app"]
    },
    watch: true
};

and want to creat gulp task that will run webpack bundling and in future do some other stuff besides.

Here is the article: https://www.npmjs.com/package/gulp-webpack I'm loooking at. It tells that I can pass webpack config like that:

 var gulp = require('gulp');
 var webpack = require('gulp-webpack');

 gulp.task('default', function() {
   return gulp.src('??')
     .pipe(webpack(require('webpack.config.js')))
     .pipe(gulp.dest('??'));
 });

So the question is: I have already told in webpack config which file to use as an entry point and where to put the result. How does gulp.src and gulp.dest fits here? Shall I put the same files as for entry and output in webpack. It might be that I'm missing some keypoint that's why it doesn't make sense.

Upvotes: 1

Views: 651

Answers (1)

kos
kos

Reputation: 5364

You can define entry point with gulp.src and omit that in webpack config.

For the gulp.dest use just destination folder path.

e.g.

 gulp.task('default', function() {
   return gulp.src('./entry.js')
     .pipe(webpack(require('webpack.config.js')))
     .pipe(gulp.dest('./dist/'));
 });

Good luck!

Upvotes: 1

Related Questions