在Vue App上为已编译元素设置默认根路径

问题描述 投票:0回答:1

当我构建我的Vue应用程序时,所有已编译的文件(vendor.js,client.js,manifest.js,client.css)都在index.html内调用,其根路径为/vendor.js,/ client.js,manifest.js和/client.js

我想在项目中指定一个根路径,以便使用我的服务器路径进行编译。

可能吗?

javascript vue.js vuejs2
1个回答
1
投票

您可以通过更改webpack配置中的输出参数来设置公共路径。

https://webpack.js.org/configuration/output/#output-publicpath

publicPath: "https://cdn.example.com/assets/", // CDN (always HTTPS)
publicPath: "//cdn.example.com/assets/", // CDN (same protocol)
publicPath: "/assets/", // server-relative
publicPath: "assets/", // relative to HTML page
publicPath: "../assets/", // relative to HTML page
publicPath: "", // relative to HTML page (same directory)
© www.soinside.com 2019 - 2024. All rights reserved.