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);
}
仅webpack时, js文件是可以生成且能被babel-loader执行, 但执行gulp时, babel-loader便没执行了.
初学webpack与gulp ~ 感谢各位指教~~
因为webpack-stream里面的webpack还是1.9.0,你用的webpackconfig已经是2.0的语法,类似rules那些。
不执行是有道理的,想用gulp+webpack的话,可以参考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:
顺便给一个别人问过的问题的答案吧。
http://stackoverflow.com/ques...