How to use gulp webpack-stream to generate a proper named file?

前端 未结 4 1363
刺人心
刺人心 2021-02-19 03:19

Currently we\'re using Webpack for our Module loader, and Gulp for everything else (sass -> css, and the dev/production build process)

4条回答
  •  北海茫月
    2021-02-19 04:03

    There was a comment to Leon Gaban's answer as to what his webpack.config.js looked like. Rather than answer that within a comment, I'm providing it here so it formats better.

    Per the docs for webpack-stream, "You can pass webpack options in with the first argument"...

    So, I did the following to force webpack to use the same output name each time (for me, I used bundle.js):

    gulp.task('webpack', ['babelify'],
        () => {
            return gulp.src('Scripts/index-app.js')
                .pipe(webpack({output: {filename: 'bundle.js'} }))
                .pipe(debug({ title: 'webpack:' }))
                .pipe(gulp.dest('Scripts/'));
    
        });
    

    The key being the options inside webpack(), which are:

    {output: {filename: 'bundle.js'} }
    

提交回复
热议问题