防止包裹自动清除控制台

问题描述 投票:0回答:3

我在我的项目中使用 Parcel 并配置如下。

{
"name": "forkify",
"version": "1.0.0",
"description": "",
"default": "index.html",
"scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html"
},
"author": "",
"license": "MIT",
"devDependencies": {
    "@parcel/transformer-sass": "^2.7.0",
    "parcel": "^2.7.0"
}

}

当我输入

npm start
并更改 js 文件中的代码然后保存它时,我的 Web 自动重新加载,但 Parcel 清除了我的 console.log(),如何防止这种行为?谢谢。

javascript parcel
3个回答
1
投票

type="module"
属性添加到
index.html
文件中的脚本标记。


0
投票

运行 npm run build 命令,然后再次重新运行 npm run start 命令。


0
投票

在index.html中,你的脚本删除defer并添加type =“module”。 像这样:

© www.soinside.com 2019 - 2024. All rights reserved.