简体   繁体   English

webpack输出文件名配置错误

[英]webpack output filename config error

When I try to run npm run webpack, this shows "Error: 'output.filename' is required, either in config file or as --output-filename." 当我尝试运行npm run webpack时,它显示“错误:'config.file或--output-filename中需要'output.filename'。”

The config file is named correctly as webpack.config.js and is also in the root directory. 配置文件正确命名为webpack.config.js,并且也在根目录中。

Below is the content in the config file: 以下是配置文件中的内容:

var path = require('path');
var webpack = require('webpack');

module.exports - {
    entry: './app.js',
    output: { path: __dirname, filename: 'bundle.js' },

    module: {
        loaders: [
            {
                test: /.jsx?$/,
                loader: 'babel-loader',
                exclude: /node-modules/,
                query: {
                    presets: ['es2015', 'react']
                }
            }
        ]
    },
};

Would really appreciate help 非常感谢您的帮助

You have a syntax error. 您有语法错误。 module.exports - should be: module.exports = And btw, you do not need to require webpack in the configuration file. module.exports-应该是:module.exports =而且,您无需在配置文件中要求使用webpack。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM