首页 > 解决方案 > 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

标签: vue.jsiiswebpack

解决方案


推荐阅读