Parcel: specify build directory

Created on 4 Sep 2019  ยท  4Comments  ยท  Source: parcel-bundler/parcel

โ” Question

How do you specify the build directory in parcel 2? I have looked all over and can't find the API for this. Is it only possible through some naming plugin or something? I was hoping for at least --out-dir with the cli.

Love this tool, and thanks in advance for any feedback!

๐Ÿ”ฆ Context

I'd like to put my built files in a sub directory, like public. That's all.

๐Ÿ’ป Code Sample

Currently running parcel build src/index.html on a very minimal React app (only index.html and index.js, no other assets included, no other plugins running).

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.1.1
| Node | 10.15.3
| npm/Yarn | 6.11.3
| Operating System | MacOS Mojave

Question

Most helpful comment

All 4 comments

@tehpsalmist there's a reference in https://github.com/parcel-bundler/parcel/issues/3377#issuecomment-521704453 on how this is done now in Parcel 2.

Basically, the location of your main setting in package.json is use. So:

"main": "dist/index.js",

@tehpsalmist The CLI --out-dir https://parceljs.org/cli.html#output-directory works for me. Perhaps also try adding --out-file to the command if it's not outputting anything.

@jasonrundell (and future readers) - Note that this issue is referring to Parcel 2 which is currently undocumented.

You'll likely get an error like this if you use dist/index.js.

๐Ÿšจ Build failed.
@parcel/namer-default: Target "main" declares an output file path of "dist/index.js" which does not match the compiled bundle type "html".
> |   "main": "dist/index.js",
> |           ^^^^^^^^^^^^^^^ Did you mean "dist/index.html"?

As the error suggests, using dist/index.html provides the expected behavior here.

Was this page helpful?
0 / 5 - 0 ratings