programing

IIS에서 vuejs 파일을 실행하는 방법

goodcopy 2022. 8. 2. 23:29
반응형

IIS에서 vuejs 파일을 실행하는 방법

따라서 requirejs-vue를 컴포넌트 로더로 사용하는 학습 목적의 데모로서 vueJs Example을 사용하고 있습니다.VS-code(단순한 http 서버)의 Live-Server 확장으로 서버를 실행하면 문제없이 정상적으로 동작합니다.단, Windows 8.1의 IIS 서버(버전 8.5)에서 이 예를 실행하면 404 Error 앱을 통해 실행됩니다.vue가 존재하지 않습니다.

Failed to load resource: the server responded with a status of 404 (Not Found)

Network devtool에서 *.vue 파일을 제외한 모든 모듈이 올바르게 로드되어 있는 것을 확인할 수 있습니다.

VueJ의 예:https://plnkr.co/edit/Y2cEa3?preview

사용 중인 IIS용 웹 구성: https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations

<?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>

PS: requirejs-vue 대신 http-vue-loader를 사용하는 다른 예도 실행했지만 IIS는 여전히 동일한 오류를 발생시킵니다.

마임을 설정해야 합니다.사용할 ".vue" 확장자 파일 입력httpvueloader/requiresjs_vue.
여기에 이미지 설명 입력
또한 수동으로 추가할 수도 있습니다.Web.ConfigIIS에서 인식할 수 있는 파일입니다.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".vue" mimeType="application/javascript"/>
    </staticContent>
  </system.webServer>
</configuration>

문제가 아직 남아 있으면 언제든지 알려주세요.

언급URL : https://stackoverflow.com/questions/61935036/how-to-run-vuejs-files-on-iis

반응형