P.Brian.Mackey P.Brian.Mackey - 1 month ago 6
React JSX Question

Getting started with React

I'm setting up React for the first time following the tutorial. I created main.js and ran the various commands. The last command gives me error:

To install React DOM and build your bundle with webpack:

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


When I run
webpack
I receive 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?

Answer

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'
  }
}
Comments