hyd*_*n97 7 html path npm bundling-and-minification parceljs
当我部署一个网站(具有多个入口点、许多 HTML 文件)并且主机使用构建命令:parcel build index.html aboutme.html. 部署的网站给我一个 404 错误。但如果我在 URL /aboutme.html 或 /index.html 中写入,就会出现...这就像一个路由问题。
HTTP://localhost:1234 => 404 错误,
HTTP://localhost:1234/aboutme.html => 正常。
有 1 个入口点,一切正常,但我想要多个 HTML 文件。
我搜索过在线命令,例如:
"build:client": "parcel build client/index.html --out-dir dist/client",
Run Code Online (Sandbox Code Playgroud)
或者
"build:server": "parcel build server/index.js --target node --out-dir dist/server",
Run Code Online (Sandbox Code Playgroud)
甚至更多使用这个奇怪的标志命令:--watch
And*_*rey 10
您需要为客户端部分做的所有事情:
npx parcel build ./*.html
Run Code Online (Sandbox Code Playgroud)
这会将结果放入 ./dist 目录
如果您现在想在包裹开发服务器上提供结果,请执行以下操作:
npx parcel ./*.html
Run Code Online (Sandbox Code Playgroud)
两个网址都可以使用
http://localhost:1234/ - 将打开您的索引
http://localhost:1234/aboutme.html - 将打开您的“关于我”
并且 - 如果您修改index.html(在根目录中,而不是在 dist 中) - 更改将自动拉到您的浏览器。