โ 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!
I'd like to put my built files in a sub directory, like public. That's all.
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).
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.1.1
| Node | 10.15.3
| npm/Yarn | 6.11.3
| Operating System | MacOS Mojave
@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.
--dist-dir was added in https://github.com/parcel-bundler/parcel/pull/4113
Most helpful comment
--dist-dirwas added in https://github.com/parcel-bundler/parcel/pull/4113