Search code examples
javascriptparceljs

Parceljs not bundling properly for prod?


i'm testing parceljs, and works fine for development. i have a normal css to just change background colors, and a very simple js file just to see if it's working.

css

body {
background-color: lightblue;
}

js

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

so all of that are working in dev mode. but i tried live server on the /dist/index.html, and all i see is the bare html. no styling, and the script doesn't render. I also tried the 'parcel build' command. and the same thing. What do I need to do?

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

Solution

  • try adding "--public-url ./" to your parcel command. More on this here: https://github.com/parcel-bundler/parcel/issues/1865