使用 webpack 生成 bundle.js & gulp

Generating bundle.js with webpack & gulp

我已经配置gulp & webpack生成一个bundle.js文件,看下面的代码:

Gulp

// Webpack
gulp.task('webpack', function() {
  return gulp.src('./app/app.js')
    .pipe(webpack(require('./webpack.config.js')))
    .pipe(gulp.dest('./build'));
});

Webpack

var path = require('path');

module.export = {
    entry: './app/app.js',
    output: {
        filename: "./build/bundle.js",
        sourceMapFilename: "./build/bundle.map"
    },
    devtool: '#source-map',
    module: {
        loaders: [
            {
                loader: 'babel',
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                query: {
                    presets: ['react', 'es2015', 'stage-2']
                }
            }
        ]
    },
    resolve: {
        root: path.resolve('./app'),
        extenstions: ['', '.js']
    }
}

基本上我的问题是文件生成正确但文件名错误,应该是 bundle.js 并且我得到一个随机文件名,例如 63432692d402c38f8df5.js

知道发生了什么吗?

在您的 webpack.config.js

中将 module.export 更改为 module.exports