简体   繁体   English

错误的根与 JavaScript 调试

[英]Wrong root with JavaScript debug

I'm using IntelliJ ultimate and working on an early POC for a web application I'm going to develop.我正在使用 IntelliJ Ultimate 并为我将要开发的 Web 应用程序开发一个早期的 POC。 I'm learning how to use webpack for the first time in this, and I'm pretty certain that things are configured properly (since the CLI did all the heavy lifting for me).我第一次学习如何使用 webpack,我很确定事情配置正确(因为 CLI 为我做了所有繁重的工作)。

Here is the HTML:这是 HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>my-app</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="/dist/build.js"></script>
  </body>
</html>

When I run this using IntelliJ's JavaScript debug configuration, it opens a URL with this address: "http://localhost:63342/my-app/index.html?_ijt=854p8s3lp1diu87uinl4mdripi".当我使用 IntelliJ 的 JavaScript 调试配置运行它时,它会打开一个带有以下地址的 URL:“http://localhost:63342/my-app/index.html?_ijt=854p8s3lp1diu87uinl4mdripi”。 This URL doesn't resolve, because /dist/build.js doesn't resolve.这个 URL 没有解析,因为 /dist/build.js 没有解析。 If I change it to /my-app/dist/build.js, it will work.如果我将其更改为 /my-app/dist/build.js,它将起作用。

I want to ditch the my-app part of that URL, since it won't be a part of the URL in any production version of an application, it's just the directory name.我想放弃该 URL 的 my-app 部分,因为它不会成为任何应用程序生产版本中 URL 的一部分,它只是目录名称。 What can I do to fix this?我能做些什么来解决这个问题?

the built-in webserver serves files from http://localhost:63342/<project root> .内置网络服务器提供来自http://localhost:63342/<project root> Forward slashes in URLs tell the browser to resolve them relative to the web server root ( localhost:63342 ), causing 404 errors. URL 中的正斜杠告诉浏览器相对于 Web 服务器根 ( localhost:63342 ) 解析它们,从而导致 404 错误。

If you like to use URLs relative to server root (the ones starting with slash), you have to change the default web path on built-in web server (to map your project to the server root).如果您喜欢使用相对于服务器根目录的 URL(以斜杠开头的 URL),您必须更改内置 Web 服务器上的默认 Web 路径(将您的项目映射到服务器根目录)。 To do this, you need editing your system hosts file accordingly - see http://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559 .为此,您需要相应地编辑系统主机文件 - 请参阅http://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559 Or, just use a 'normal' web server (Apache, etc.) to host your files and configure it in the way you like或者,只需使用“普通”Web 服务器(Apache 等)来托管您的文件并按照您喜欢的方式对其进行配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM