bob
bob

Reputation: 933

How do I get webpack-dev-server to serve files?

I'm going through the docs for webpack 4 and trying to get webpack-dev-server running from a very simple configuration.

I've installed webpack-dev-server and added minimal configuration for it in my webpack.config.js:

const path = require('path');

module.exports = {

    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dist/js'),
        filename: 'bundle.js'
    },

    watch : true,

    devServer: {
        contentBase: './dist',
        port: 9999
    }

}; //config ends

However, when I run webpack and then navigate to http://localhost:9999, nothing is being served. There is no server listening for connections.

Upvotes: 1

Views: 3794

Answers (1)

Tan Duong
Tan Duong

Reputation: 2142

You should change contentBase: './src' to make webpack-dev-server understand what is the directory you used for develop.

The output param is used for build to production not for webpack-dev-server

Upvotes: 1

Related Questions