Skip to content
Advertisement

How to provide contentBase and publicPath in wepack-Dev-server

Recently i setup a webpack-dev-server by watching a tutorial. I did exactly what exactly he did in the video

I expected that It will start a Live server, but it didn’t. I already check the internet but nothing good happenedenter image description here

Advertisement

Answer

Please refer to this link: https://webpack.js.org/configuration/dev-server/#publicpath

Since Webpack has been migrated from v3 to v4 so the syntax is different.

You need to change your devServer configs as below:

devServer: {
    static: {
      directory: path.resolve(__dirname, "static"),
      publicPath: "/static-public-path/",
    },
  },
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement