question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parcel2 build command outputs bundles in my src folder instead of dist folder.

See original GitHub issue

🐛 Parcel2 build command outputs bundles in my src folder instead of dist folder.

When I run the parcel build ./src/index.html --dist-dir ./dist the bundle will get outputted to my src directory instead of the dist directory. Running parcel serve ./src/index.html works as expected.

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "my app",
  "version": "1.0.0",
  "description": "This is a app",
  "main": "src/index.html",
  "scripts": {
    "start": "parcel serve ./src/index.html",
    "build": "parcel build ./src/index.html --dist-dir ./dist",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Andrew",
  "license": "ISC",
  "alias": {
    "components": "./src/components",
    "containers": "./src/containers",
    "style": "./src/style",
    "assets": "./src/assets",
    "libs": "./src/libs",
    "workers": "./src/workers",
    "db": "./src/db"
  },
  "devDependencies": {
    "parcel": "next",
    "sass": "^1.26.11"
  },
  "dependencies": {
    "bulma": "^0.9.1",
    "lunr": "^2.3.9",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0"
  }
}

🤔 Expected Behavior

It should build to ./dist even without the additional flag.

😯 Current Behavior

Throws all bundle files and replaces my index.html with the bundle version.

🔦 Context

I’m building a very basic app using React to try out Parcel v2. I never experienced this issue using Parcel v1. Was really hoping to migrate the team to v2. 😢

💻 Code Sample

N/A

🌍 Your Environment

Arch Linux 64x

Software Version(s)
Parcel 2.0.0-beta.1
Node v12.19.0
npm/Yarn 6.14.7/1.22.10
Operating System Arch Linux

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mischniccommented, Oct 26, 2020

Remove this line:

	"main": "src/index.html",

Duplicate of https://github.com/parcel-bundler/parcel/issues/4255 (because the src folder should never be overwritten because of a configuration error).

(Also, --dist-dir ./dist isn’t needed, that’s the default already).

0reactions
RichardJECookecommented, Jul 16, 2021

ok thanks. What should it point to please? My html file is the root of my build

Read more comments on GitHub >

github_iconTop Results From Across the Web

CLI - Parcel
The parcel CLI is the most common way to use Parcel. It supports three different commands: serve, watch, and build.
Read more >
Parcel is not creating a dist folder when I use build command
When I use the npm start command, it creates a dist folder and server it on localhost, port:1234. But when I use the...
Read more >
Bundling and Building with Parcel - Beginner JavaScript
In the terminal, navigate to the dad jokes module refactor exercise folder and install it as a dev dependency using the following command...
Read more >
parcel - npm
The actual (somewhat complete) documentation for Parcel 2 is available here: ... Configure the directory where compiled assets are output.
Read more >
Package management basics - Learn web development | MDN
dist : The distribution directory — these are the automatically packaged, minified files Parcel has built for us, and the files it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found