Full Github project: https://github.com/pbrianmackey/uiexperiment
I run
webpack-dev-server --content-base deployment/
Then go to http://localhost:8080/
, Error
Cannot GET /
I think the problem is a misconfiguration of webpack. I checked by webpack.config.js file and don't see a problem. How can I fix this so I get my hello world example?
It could be a routing problem too. I think I can use this website without react-router, but I could be wrong. There are no errors in webpacks output on the console.
import "babel-polyfill";//for flipping IE import $ from 'jquery'; import jQuery from 'jquery'; var App = require('./app'); var React = require('react'); var ReactDOM = require('react-dom') var Hello = React.createClass({ render: function() { return <div>Hello {this.props.name}</div>; } }); ReactDOM.render( <Hello name="World" />, document.getElementById('container') );
What is the default port where webpack server runs? 8080 ? The default port to run web-pack-server is 8080.
You can also enable watch mode from your Webpack config file: module. exports = { mode: 'development', watch: true, // Enable watch mode entry: { app: `${__dirname}/app.
webpack-dev-server is Webpack's officially supported CLI-based tool for starting a static server for your assets. While you don't need any CLI tools to use Webpack, webpack-dev-server gives you a single command that starts a static server with built-in live reload.
Turns out I had index.html in the wrong place. From the webpack docs:
To load your bundled files, you will need to create an index.html file in the build folder from which static files are served (--content-base option).
I made a copy of index.html in a new folder I called deployment
to match what I specified in the output.path
In the webpack.config.js
put this :
devServer: { historyApiFallback: true, }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With