Gulp and Webpack-stream Integrated configuration

Source: Internet
Author: User

Webpack is very powerful, but there are deficiencies, batch processing is still gulp better. Can we combine the advantages of both? This article explains how to integrate gulp and Webpack

1. Installing Webpack-stream

Very important plug-ins, of course, can also directly use the official Webpack, integrated way can see Webpack official website. But Webpack-stream is more consistent with Gulp's streaming syntax.

install --save webpack-stream vinyl-named

Windows users remove sudo, vinyl-named is used to keep the input and output the same file name, otherwise it will automatically generate a hash.

2. Writing the configuration file: Gulpfile.js
var gulp =Require' Gulp ');var webpack =Require' Webpack-stream ');var named =Require' vinyl-named ');var webpackconfig =Require"./webpack.config.js"); Gulp.task (' webpack ', function() { return gulp.src ('./www/ Src/main.jsx '). Pipe (named ()). Pipe (Webpack (webpackconfig)). Pipe (Gulp.dest ('./www/build/');});   
Webpack.config.js

Note: You do not need to configure entry and output with Webpack-stream

Module.exports = {Watchtrue, Devtool:  "Source-map",  resolve: { extensions: [ ",  JS ',  '. Jsx ']}, module: { test:/\.jsx$/, loader:  query: { presets: [ Es2015 ',  ' React '}}, { test:/\.js$/, Loader:  ' Babel-loader ',  query: { presets : [ ' es2015 ']}}]}};           

Gulp and Webpack-stream integration configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.