使用webpack&生成bundle.js吞

时间:2016-03-17 15:06:18

标签: javascript gulp bundle webpack

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

咕嘟咕嘟

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

知道发生了什么事吗?

enter image description here

1 个答案:

答案 0 :(得分:2)

将webpack.config.js

中的module.export更改为module.exports