我们可以在webpack中使用相对静态文件夹吗?
我创建了一个使用Webpack作为构建工具的Vuejs应用程序 . 结构是这样的,我将所有图像/视频置于静态但js / css下的资产:
只要应用程序以root身份分发,该应用程序就可以正常运行 .
即 http://<domain>/index.html
但我想将它分发到一个子文件夹下,这个相同的分发代码无需重新编译就可以工作,因为它可能会由不同的操作团队移动 .
即
http://<domain>/<app>/index.html
http://<domain>/<app>/index.html
http://<domain>/<app>/<app>/index.html
这会弄乱所有静态资源 . 所以我做了一些研究:
http://vuejs-templates.github.io/webpack/static.html
并且使用我的设置assetsPublicPath,而不是特定于子文件夹名称,使用./或“”,但它不起作用 .
assetsPublicPath: '/',
assetsSubDirectory: 'static'
是否有办法打包静态文件夹,使其像相对路径一样工作,还是需要将所有资源移动到资产?
提前致谢 .
1 回答
今天发生在我身上,我通过删除node_modules修复此问题,重新安装node_modules,关闭,开机( reboot didn't work for me, i have to shutdown and power on )
我想这里有一些缓存 . 因此,解决此问题的最佳方法是重新安装node_modules并关闭电源,然后再打开电源
这也可能有所帮助:https://github.com/vuejs-templates/webpack/issues/79
你说:
....., try upgrading vue-cli to the latest version and confirm that things are fixed with a fresh project?