programing

Create-React-App 어플리케이션의 index.html과 index.js 사이의 접속처는 어디입니까?

showcode 2023. 3. 16. 22:03
반응형

Create-React-App 어플리케이션의 index.html과 index.js 사이의 접속처는 어디입니까?

Create React App을 사용하기 시작했는데 어떻게 해야 하는지 이해할 수 없습니다.index.js로딩되어 있습니다.index.html다음은 html 코드입니다.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <!--
      Notice the use of %PUBLIC_URL% in the tag above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start`.
      To create a production bundle, use `npm run build`.
    -->
  </body>
</html>

하지만 나는 어디에도 그 수입품이 보이지 않는다.index.js어디서 연결되죠?제가 무엇을 빠뜨리고 있나요?

Create React App은 후드에서 html-webpack-plugin이 포함된 웹 팩을 사용합니다.

구성에서는 웹 팩이 다음을 사용하도록 규정하고 있습니다.src/index.js"진입점"으로 지정됩니다.이것이 첫 번째 모듈입니다.이 모듈에서 다른 모듈로 이동하여 하나의 번들로 컴파일합니다.

웹 팩은 자산을 컴파일할 때 단일 번들(또는 코드 분할을 사용하는 경우 여러 번들)을 생성합니다.그러면 모든 플러그인이 최종 경로를 사용할 수 있습니다.HTML에 스크립트를 삽입하기 위해 이러한 플러그인을 사용하고 있습니다.

HTML 파일을 생성할 수 있도록 html-webpack-plugin을 활성화했습니다.이 설정에서는, 다음의 값을 읽도록 지정했습니다.public/index.html템플릿으로 사용합니다.또,inject 수 있는 선택권true이 옵션을 사용하면html-webpack-plugin를 추가합니다.<script>웹 팩에 의해 제공되는 경로를 최종 HTML 페이지에 직접 입력합니다.이 마지막 페이지는 당신이 볼 수 있는 페이지입니다.build/index.html실행 후npm run build, 및 에서 서비스를 제공받는 서비스/달릴 때npm start.

Create React App의 장점은 실제로 생각할 필요가 없다는 것입니다.

테크놀로지는 전혀 관련이 없고 서로 관련이 없기 때문에 아무것도 빠뜨리지 않습니다.Webpack/npm/node/json/next/react/typscript/web3는 완전히 Apache와 HTML을 사용하는 것만으로 이루어집니다.솔직히 KISS를 이용하는 것이 최선이며, 큰 보안 리스크일 뿐만 아니라 개발할 가치가 없는 다른 것들은 사용하지 않는 것이 좋습니다.

언급URL : https://stackoverflow.com/questions/42438171/wheres-the-connection-between-index-html-and-index-js-in-a-create-react-app-app

반응형