[英]How to change the path structure from built Vue project?
So I have a Vue project created with the handy vue ui command.所以我有一个使用方便的 vue ui 命令创建的 Vue 项目。 package.json has the build script to compile the project in the dist folder.
package.json 在 dist 文件夹中有编译项目的构建脚本。
An issue I'm facing is that the index.html file references to js and css files this way:我面临的一个问题是 index.html 文件以这种方式引用 js 和 css 文件:
<link href="/js/app.66f30e0a.js" rel="preload" as="script">
<link href="/js/chunk-vendors.410e1ec5.js" rel="preload" as="script">
<link href="/css/app.20c14d91.css" rel="stylesheet">
<script src="/js/chunk-vendors.410e1ec5.js"></script>
<script src="/js/app.66f30e0a.js"></script>
But I need it to do it this way because of the software I'm putting these files on:但我需要它这样做,因为我将这些文件放在上面的软件:
<link href="./js/app.66f30e0a.js" rel="preload" as="script">
<link href="./js/chunk-vendors.410e1ec5.js" rel="preload" as="script">
<link href="./css/app.20c14d91.css" rel="stylesheet">
<script src="./js/chunk-vendors.410e1ec5.js"></script>
<script src="./js/app.66f30e0a.js"></script>
So basically adding the period character before the path.所以基本上在路径之前添加句点字符。
I know this can be changed somehow using webpack, but this is using babel and I'm a total novice in terms of project config.我知道这可以使用 webpack 以某种方式更改,但这是使用 babel 并且我在项目配置方面完全是新手。 This is the babel.config.js file right now:
这是现在的 babel.config.js 文件:
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
What would I need to add/change in order to get the path structure I want?为了获得我想要的路径结构,我需要添加/更改什么?
Thanks in advance.提前致谢。
You just need to add a vue.config.js
file into your project root, and inside something like:您只需将
vue.config.js
文件添加到您的项目根目录中,并在类似的内容中添加:
module.exports = {
publicPath: './'
}
For further reading, see the Vue cli docs .如需进一步阅读,请参阅Vue cli 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.