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...