var gulp = require('gulp');
var webpack = require('webpack-stream');
var named = require('vinyl-named');
gulp.task('default', function () {
return gulp.src('./resource/js/app.js')
.pipe(webpack( require('./webpack.config.js') ))
.pipe(gulp.dest('./public/js/'));
});
module.exports = {
entry : './resource/js/app.js',
output : {
filename : 'bundle.js'
},
module : {
rules : [
{
test : /\.js$/, use : {
loader : 'babel-loader',
options : {
presets : ['es2015']
}
}}
]
}
};
import './a.js';
function helloworld()
{
console.log(1);
}
When only webpack is used, js files can be generated and executed by babel-loader, but when gulp is executed, babel-loader is not executed.
Beginner to webpack and gulp~Thank you for your advice~~
巴扎黑2017-05-19 10:38:28
Because webpack in webpack-stream is still 1.9.0, the webpackconfig you use already has 2.0 syntax, similar to rules.
It makes sense not to execute it. If you want to use gulp+webpack, you can refer to webpack-stream
If you would like to use a different version of webpack than the one this plugin uses, pass in an optional 2nd argument:
var gulp = require('gulp');
var webpack2 = require('webpack2');
var gulpWebpack = require('webpack-stream');
gulp.task('default', function() {
return gulp.src('src/entry.js')
.pipe(gulpWebpack({}, webpack))
.pipe(gulp.dest('dist/'));
});
By the way, let me give you an answer to a question that others have asked.
http://stackoverflow.com/ques...