Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

vue项目添加publicPath后无法build #342

Open
xietongjian opened this issue Aug 18, 2019 · 7 comments
Open

vue项目添加publicPath后无法build #342

xietongjian opened this issue Aug 18, 2019 · 7 comments

Comments

@xietongjian
Copy link

image
image
,如果将publicPath设置成‘/’就没问题。
想要打包后放入nginx二级目录下,请问如何解决。

@piedasing
Copy link

I have the same problem, too.

@mgluobo
Copy link

mgluobo commented Sep 30, 2019

一样的问题,而且如果不设置publicPath 静态资源的访问也有问题 设置了pubicpath就编译不起

@26000
Copy link

26000 commented Oct 24, 2019

I found a possible solution and wrote about it here. I hope it helps!

@light0x00
Copy link

light0x00 commented Jan 2, 2020

和vue不vue没有关系. 还有这个插件不会影响的你的构建, 因为轮到它执行的时候你的项目已经构建结束了.

@hyteraesa
Copy link

我也有同样的问题 请问你找到解决的办法了吗? @xietongjian

@BobZzz
Copy link

BobZzz commented Mar 12, 2020

我也遇到了这个问题,vue-cli2,用了几个方法都不行

@waitkafuka
Copy link

waitkafuka commented Oct 12, 2021

看来这是一个共性问题。这是由于prerender所启动的服务器找不到js文件导致的。
解决方案是:
在vue.config.js文件,如下:

module.exports = {
  publicPath: "/publicPath/",
  outputDir: path.join(__dirname, "./dist", "/publicPath/"),
}

这样会在dist目录下生成一个/dist/publicPath这样的文件夹。
对应插件配置为:

const options = {
  staticDir: path.join(__dirname, "dist/"), //这里写到dist目录为止
  indexPath: path.join(__dirname, "dist/publicPath/index.html"), //重要
}

如果还有问题可以联系我微信zks_1927

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants