【问题标题】:Parceljs not bundling properly for prod?Parceljs 没有正确捆绑产品?
【发布时间】:2020-02-28 13:45:24
【问题描述】:

我正在测试 parceljs,并且适用于开发。我有一个普通的 css 来改变背景颜色,还有一个非常简单的 js 文件来看看它是否工作。

css

body {
background-color: lightblue;
}

js

document.getElementById('app').textContent = 'hey'

所以所有这些都在开发模式下工作。但我在 /dist/index.html 上尝试了实时服务器,我看到的只是裸 html。没有样式,并且脚本不会呈现。我还尝试了“包裹构建”命令。和同样的事情。我需要做什么?

package.json

{
  "name": "parceltest1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "parcel ./src/index.html",
    "build": "parcel build ./src/index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "parcel-bundler": "^1.12.4"
  }
}
Failed to load resource: the server responded with a status of 404 (Not Found)
Refused to apply style from 'http://127.0.0.1:5500/src.e31bb0bc.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

【问题讨论】:

    标签: javascript parceljs


    【解决方案1】:

    尝试在您的 parcel 命令中添加“--public-url ./”。 更多信息在这里:https://github.com/parcel-bundler/parcel/issues/1865

    【讨论】:

    • 这是不是默认设置的最愚蠢的事情...如果您在应用程序中使用...文件夹...,则整个应用程序的链接已损坏?这是“超级简单,零配置”的捆绑器?在我(不合格)看来,这是可怕的默认行为。 +1 的答案,为我工作
    猜你喜欢
    • 2019-06-27
    • 2013-06-16
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多