vue.js - Vuejs 部署到 IIS 默认网站应用程序
问题描述
我需要帮助将 VueJS 应用程序作为附加应用程序部署到 IIS 默认网站。
我可以在新端口(端口 80 除外)上将构建的 Vue 站点添加为自己的 IIS 网站。我将 vue.config.js publicPath 属性更改为“./”并将新站点指向构建的“dist”文件夹。这很好用
当我尝试在默认网站下添加新的“应用程序”时,我无法工作。这允许您使用默认端口 (80) 并将“别名”名称附加到 URL。前 - 本地主机/myvuesite
过去,我已经让它在其他公司的 ASP.NET 网站上正常工作,但我无法让它与 Vue 一起工作。当我尝试导航到我新创建的站点 localhost/myvuesite 时,我只是得到一个空白页面,没有任何内容可显示。当我检查 chrome 源时,该站点似乎下载了 .js 和 .css 以及 index.html 文件,但有些东西无法正常工作。
'dist' 目录中的 web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
vue.config.js:
module.exports = {
publicPath: './',
productionSourceMap: false
};
文件结构:
myvuesite
- css
- img
- js
- favicon.ico
- index.html
- web.config
解决方案
推荐阅读
- python - 在导入时将变量传递给自写模块?
- c# - 尽管显然发生了碰撞,但 OnCollisionEnter2D 未激活
- flutter - 如何设置或移除按钮(RaisedButton)角半径?
- reactjs - 做出反应。导入 svg
- bash - 3. 如何获取当月的星期三的日期
- c - 以二进制 64 位表示形式打印 long
- algorithm - 如何对具有唯一值的数组进行排序
- javascript - 从 React 14 升级到 React 16 时 react-modal 抛出错误
- r - R - 将数据帧中不同字符串长度的列拆分为仅包含一个字符的多列
- javascript - Sort nested divs inside unordered list