且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 webpack 开发服务器中提供静态资源

更新时间:2023-11-22 11:39:46

当从浏览器加载时,你可以告诉 webpack 使用不同的路径.

You can tell webpack to use a different path when loading from the browser.

在你的 webpack 配置文件的 output 部分添加一个 publicPath 字段指向您的 assets 文件夹.

In the output section of your webpack config file add a publicPath field pointing to your assets folder.

webpack.config.js

output: {
  // your stuff
  publicPath: '/assets/'
}