V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
chenglichengwai
V2EX  ›  React

突然发现的关于 create-react-app 的奇怪问题

  •  
  •   chenglichengwai · Oct 15, 2020 · 2871 views
    This topic created in 2029 days ago, the information mentioned may be changed or developed.

    使用 create-react-app 创建的项目,index.html 中并没有 script 引用 index.js,为什么项目可以正常启动,这个是怎么实现的,有大佬知道吗?或者推荐几本书也可,刚开始学习

    5 replies    2020-10-23 03:01:11 +08:00
    LOWINC
        1
    LOWINC  
       Oct 15, 2020
    eject 后 ./config/webpack.config.js 可以看到 是用的 HtmlWebpackPlugin


    https://www.webpackjs.com/plugins/html-webpack-plugin/
    no1xsyzy
        2
    no1xsyzy  
       Oct 16, 2020
    根据 #1 和我对这个插件的知识,应该你把 index.html 删了都能正常启动?不清楚是否会受到输入的影响而把一些信息带进去,但并不必要 src 有 index.html
    TrickWu
        3
    TrickWu  
       Oct 16, 2020
    这个不是 webpack 处理自动注入得么
    chenglichengwai
        4
    chenglichengwai  
    OP
       Oct 16, 2020
    @no1xsyzy 删了 index.html 报错了,-_-我还是在开发阶段,就用 yarn start 启动了一下.另外楼上的大佬,看到依赖里有很多 webpack 的包,还没有做 webpack.config 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5712 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 06:54 · PVG 14:54 · LAX 23:54 · JFK 02:54
    ♥ Do have faith in what you're doing.