我想部署一个静态nuxt.js应用程序(用nuxt generate
构建)到Web服务器的子目录.默认情况下,nuxt将生成的文件放在dist
目录中:
如果我在dist
文件夹的parent directory上启动一个Web服务器,并用以下命令打开页面:
http://localhost:34360/dist/
站点无法从域根目录加载脚本文件:
我try 在nuxt配置中设置publicPath
属性:
build: {
publicPath: '/dist/'
}
应用程序编译为:
现在,nuxt将脚本文件下移一级(/dist/dist),并再次在根级别(/dist)上搜索,因此仍然找不到文件
How can I configure the site, such that scripts and assets are loaded and it is self contained, no matter on which directory on my server I put it?
这个问题已经讨论了on GitHub次,但建议的提示(使用publicPath)没有起作用,如上所示.
旁注:我不想指定publicPath absolut(即http://localhost:8080/dist
),它可以工作,但会产生新问题.