I know that it's a goal of this project not to add any Parcel-specific config files, but is there any way that to set this up once and not have to pass the option every time?
If not, I think it's sorely needed.
I do not know specifically the answer to your question, but you can achieve mostly the same with the "scripts" section of the package.json file, like this:
"scripts": {
"build": "parcel build --out-dir out www/index.html"
}
Then, just run it:
$ npm run build
@pierredavidbelanger That's pretty good, I suppose.
On a different note: Is there a "build" for development? It seems like that's sort of a missing option. I suppose it's not so bad to watch and then just ctrl-c but it seems like building for production should have been a flag and not the whole build command.
Alternatively, the default parcel <file> could have been build for dev, but for some reason it assumes serve which is already a separate command. Seems an odd choice, to me.
I guess you are searching for parcel build --no-minify index.html to build for "dev" and parcel build index.html to build for prod.
This is really strange but now my output file name is some crazy random name:
78bfe7508e2986e20ac4eb8ff6ea87bd.js
The "crazy random name" is a hash, it is intended and it is useful to bust cache :)
I figured as much. And I also figured out how to get back the normal name: I had left off the .js extension in the input file my command, adding it back gave me back the normal name. This had me dumbfounded for a minute because I swore I was just running the same command I ran earlier and getting different results.
What's the reasoning for this behavior? I get the point of a hashed name but shouldn't it be an option and not sort of "hidden" by having to know to leave off the extension? It's a bit esoteric.
I am sorry, I am confused by your last comment.
I hope someone not newbe as me with parcel will be able to help you :)
Or is that a bug? To be clear, this is the command I used:
$ parcel build public/js/main.js -d public/dist
built ... public/dist/main.js
And the output file name was also main.js as expected. Then, without the .js it gave me the hash name.
$ parcel build public/js/main -d public/dist
built ... public/dist/78bfe7508e2986e20ac4eb8ff6ea87bd.js
Oh I see,
In the first command, you are building a specific file, this file is the entry point, the entry point file name is never a hash.
In the second command, you are building a folder, parcel will build this as a module (so it must contains an index.js).
I guess you already read the Getting Started section that explain very well the main use case.
I suggest you head over to the chat if you have others questions like that (or feedbacks, or suggestions).
I'll close this of as Parcel is currently a CLI tool (with an API) and can only be used using the cli (or a self-made script that uses the api)
So like @pierredavidbelanger already said u can use this to keep it stored
"scripts": { "build": "parcel build --out-dir out www/index.html" }
I'll close this of as Parcel is currently a CLI tool (with an API) and can only be used using the cli (or a self-made script that uses the api)
So like @pierredavidbelanger already said u can use this to keep it stored"scripts": { "build": "parcel build --out-dir out www/index.html" }
i'm running parcel ^2.0.0-alpha.3.2 and got error: unknown option --out-dir'
Will be added back as --dist-dir in the next alpha: https://github.com/parcel-bundler/parcel/pull/4113