简体   繁体   English

如何在 wepack-Dev-server 中提供 contentBase 和 publicPath

[英]How to provide contentBase and publicPath in wepack-Dev-server

Recently i setup a webpack-dev-server by watching a tutorial.最近我通过观看教程设置了一个 webpack-dev-server。 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 inte.net but nothing good happened enter image description here我已经检查了 inte.net 但没有发生任何好事enter image description here

Please refer to this link: https://webpack.js.org/configuration/dev-server/#publicpath请参考这个链接: https://webpack.js.org/configuration/dev-server/#publicpath

Since Webpack has been migrated from v3 to v4 so the syntax is different.由于 Webpack 已从 v3 迁移到 v4,因此语法不同。

You need to change your devServer configs as below:您需要更改您的devServer配置如下:

devServer: {
    static: {
      directory: path.resolve(__dirname, "static"),
      publicPath: "/static-public-path/",
    },
  },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM