
This makes sure that the destination folder is empty before running your build. Also notice that the webpack task relies on the clean task to be run first. In the webpack task we're simply passing the exported config from and handing it over to webpack-stream. It comes in handy when diagnosing build issues. The gulp-print package is optional, but I find it useful to print out what files are getting piped around. In the clean task, we're taking a stream of all the files from the /del isn't stream based, so the vinyl-paths package is used to get the file paths out of the stream and pass them into del. There are only 2 gulp tasks defined clean and webpack.

I'm keeping this gulpfile.js file fairly minimal for the sake of the post. const gulp = require('gulp') Ĭonst vinylPaths = require('vinyl-paths') Ĭonst webpack_stream = require('webpack-stream')Ĭonst webpack_config = require('./') If you don't have one already just create an empty file in your project root. Next, let's add the Gulp task to the gulpfile.js file in your project. npm install webpack-stream gulp-print gulp-util del vinyl-paths -save-dev Go ahead and grab it from NPM along with a few other packages that we'll make use of.

This package will allow Webpack to be run in a stream which is what we need. To plug Webpack into a Gulp task we're going to use the webpack-stream package. Make sure your command terminal is located at your project root. Running the following commands will take care of that for you. Let greeting: string = greeter.getGreeting() īased on the Gulp documentation, its recommended to install the gulp-cli globally in addition to installing a local version of Gulp as a devDependency in your package.json file. Let greeter : Greeter = new Greeter('Cecil') As a quick catch up, here's what the and *.ts files look like. I'm going to build off the TypeScript project that was created in a previous post.

Now if you have Gulp already setup then you can skip this section. In this post, we'll see how to have Gulp use Webpack for bundling. Actually, I have gulp tasks in a file that I tend to just copy what I need from it into new projects and tweak accordingly. If you're like me, you may already have made an investment in adding Gulp to many of your new and existing projects. Depending on the tool you use to scaffold your web project, you may already have support for Gulp ready to go.

It has an solid community that's continuing to add new features and plugins to make setting up your build pipeline easier. Gulp has been a popular task automation toolkit in the frontend web development space for some time now.
