包裹不会将更改重新加载到HTML页面

我正在尝试使用Parcel并开始运行,但无法使用基本设置。我想提供一个静态HTML页面,该页面在更改后会自动重新加载。

当我转到http://localhost:1234时,包裹将送达我的页面。如果我在index.html中进行了任何更改,则不会重新加载...或重新加载空响应。

版本

parcel: 1.12.4
npm: 6.12.1
node: v13.3.0

index.html

<!doctype html>
<html>
    <head>
        <title>Tinsel town</title>

        <script src="app.js"></script>
    </head>

    <body>
        <h1>Tinsel…</h1>
    </body>
</html>

app.js

// empty

外壳

matt$ parcel index.html --log-level 5
[13:20:42]: Server running at http://localhost:1234 
[13:20:42]: Building...
[13:20:42]: Building index.html...
[13:20:43]: Building app.js...
[13:20:43]: Built app.js...
[13:20:43]: Built index.html...
[13:20:43]: Producing bundles...
[13:20:43]: Packaging...
[13:20:43]: Building hmr-runtime.js...
[13:20:43]: Built ../../../usr/lib/node_modules/parcel-bundler/src/builtins/hmr-runtime.js...
[13:20:43]: ✨  Built in 477ms.
[13:20:49]: Building...
[13:20:49]: Producing bundles...
[13:20:49]: Packaging...
[13:20:49]: ✨  Built in 2ms.
gansinimabi 回答:包裹不会将更改重新加载到HTML页面

问题是

Vim及其保存文件的方式。

当保存在 Vim 中时,它将重命名您正在编辑的文件,并将当前缓冲区保存到文件位置:

           +------------+       +---------------------------------+
           | index.html +------>+ ~/.cache/vim/backup/index.html~ |
           +------------+       +---------------------------------+


                            index.html is now kaput!

              (no `MODIFY` filesystem event fired,only `DELETE`)


                        +----------+       +------------+
                        | *buffer* +------>+ index.html |
                        +----------+       +------------+

                        (`CREATE` filesystem event fired)

可以通过在backupcopy中将yes设置为.vimrc来更改此默认行为:

set backupcopy=yes " Necessary for ParcelJS to work

这将导致 Vim 直接写入您正在编辑的文件,从而导致modification事件在文件系统中触发。包裹就是这个,就是这个。

本文链接:https://www.f2er.com/2957593.html

大家都在问