javascriptreactjswebpack

Getting started with React, webpack error: "Output filename not configured"


I'm setting up React for the first time following the tutorial. I created main.js and ran the various commands:

To install React DOM and build your bundle with webpack:

$ npm install --save react react-dom babel-preset-react
$ webpack

But when I run the last command, webpack, I get an error:

Output filename not configured

It points me to the usage docs. The usage docs tells me the command line interface expects input of the form:

webpack <entry> <output>

Obviously the command webpack as shown in the React tutorial does not meet this criteria. What did I do wrong?


Solution

  • Create a webpack.config.js, eg.:

    module.exports = {
      context: __dirname + "/app",
      entry: {
        jsx: './main.js',
        html: './index.html'
      },
      output: {
        path: __dirname + '/dist',
        filename: 'bundle.js'
      }
    }