New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy all files from a predefined folder into the dist folder #1411
Comments
So there is no current way on parcel to just copy some files, right ? |
Not sure why this is such a requested feature.
In practise parcel wouldn't probably be the only command you run on a build anyways. However the original issue doesn't seem to be about copying it's more about naming? |
That works on initial build, but won't do anything when you add files after parcel starts. You'd have add your own watch task to do it. Definitely possible to do, but not as convenient |
My concern will be probably more about entry points than just copying files. |
Thanks! |
I have a real use-case for this — we are using model loaders in Three.js. Just using Three.js is already a good use-case: copying over the "examples" folder (which is more of a set of required plugins than examples) is almost mandatory since Three doesn't use That's all doable, and is more of a problem with Three.js than it is with Parcel however, so it's not too big of a deal. The big issue is when importing files like GLTFs. GLTFs are 3D models that consist of two separate files: a |
i'm using this with my three js project |
I ended up using https://www.npmjs.com/package/parcel-plugin-static-files-copy with a few modifications (the original doesn’t handle bundles with multiple entry files at all). |
All the people trying to build the project on Windows would be thrilled by that |
This is not working without entry file. Very bad. |
not working as well. |
@DeMoorJasper I definitely agree with you that is probably not the concern of parceljs to copy static files when building the distribution, but how to prepare that files when running BTW, |
I'm not sure why there is so much resistance about copying assets. I am not trying to be critical, it's just an observation. I ran into this when trying to access raw Anyway, I used |
…g of status files like the 3D GLTF model. Using the npm package "parcel-plugin-static-files-copy" should work according to the following post: parcel-bundler/parcel#1411 (comment)
The one @etoxin posted worked flawlessly. |
I also find it weird not to support a static folder by default. There's just such a variety of very different reasons to want to be able to predict the location of a group of static files and just being able to have a This plugin looks nice, but I'm currently not able to access the files on the localhost dev server, if something is in I'm currently trying to figure out how to link to a file for a favicon that's set dynamically by vue-meta based on a computed property.. and I just can't.. have a bunch of icons in assets/icons/*.png.. and can't seem to get access to them. I have this:
but i don't really know how to 'tell' parcel that all the files in this directory are needed. If there was a sort of static folder that persisted between dev and dist (common pattern in a lot of site generators) i imagine it'd just work. |
My use case is for social media images. Eg. <meta name="twitter:image" content="./assets/cover.jpg" /> It will resolve to correct path, however, twitter (and FB) crawlers require full URL to be present here (starting with |
I would like to +1 this request. I have yet to try any of the plugins mentioned (but I will soon!), but my use case for this was spritesheets and Pixi.js. Pixi.js is a 2D rendering engine, with a import spritePath from '~assets/sprite.png' and then passing the path: PIXI.Loader.shared
.add('sprite', spritePath)
.load(callback); However, like @j0hnm4r5 ' use-case, the same didn't work for Thanks for the Parcel plugin recommendations! I can see it has been iffy getting either of the plugins working for some users here, but I hope I luck out. |
This is a feature that would add almost no complexity to Parcel's CLI and would be, probably, easy to implement, so I see a nice cost-benefit from implementing it. I get the reason why the maintainer thinks this is not so useful of a feature, as we all should be very comfortable with moving files around when needed. To me, though, it is clear that it would be a convenience feature, what doesn't sound too important but collides with the fact that Parcel.js itself is a huge convenience library that people use so they don't have to do things by hand. |
I just want to add that this will cover one more base for running parcel in a CI environment. |
yes please |
Yep please add this. |
What does people have against the mentioned plugins? |
Nothing in particular against plugins or command lines. |
They don't work with Parcel 2. I think the easiest way for Parcel to support this is to specify a "no-transform transform" for unsupported filetypes, so that if I run Solution for Parcel 2And… good news! It exists: // in your .parcelrc
{
extends: ['@parcel/config-default'],
transformers: {
'*.png': ['@parcel/transformer-raw']
}
} parcel build 'images/*' |
This can be solved using the raw importer or https://parceljs.org/features/development/#api-proxy and a cp command on production build |
Where are those modifications? :( I still have this issue and I'm trying a way to solve it |
🙋 feature request
I've seen some other feature request that has a similar idea, but in different ways, and other requests that might be solved by using a feature like this one.
I would like to have the ability to include files in the build process without requiring them in code.
This is very useful and also results in better-looking output, and easier for cache management, especially in service workers(arguably), but anyways its much better to have an idea of the final file/folder structure of the project.
Also, I think that its better to handle some files that way than letting Parcel treat them differently than the other files, like for example the SW(in some cases), or if you need to dynamically import images from a folder, and you can't know ahead of time the names of the files.
This feature can help with #301 and #557
🤔 Expected Behavior
All the files within the folder called(for example)
assets
will be copied as is, and without change into thedist
folder.will be copied to the root of the dist folder:
😯 Current Behavior
Only files required inside the bundle are copied to the
dist
folder and you have to know the names of all of them beforehand and have them beforehand.💁 Possible Solution
It's a pretty simple feature, so I would say that there are two ways of implementing this.
🔦 Context
The text was updated successfully, but these errors were encountered: