Sorry about the strange title, let me explain.
First, I think it's a bit strange that the built assets files are placed in the same location as the static files manually added. What was the reason for this? Why not have the built assets in /assets and the manually added files in /static?
Second, how would one add root items, for example favicon.ico or .htaccess? Perhaps a config option for the static files would be useful, for example /static/ as default but could be set to / for adding the files at root level.
I'm open to this change, though would prefer to just have static always compile to root, rather than providing an option. @linusborg @zigomir Thoughts?
Less options = less config = better imho.
Options are a bad thing? I disagree.
Why even have an option for the name of the assets folder then? Forcing them to use the folder you chose is not better.
If your concern is that it will require more configuration at setup, then that's handled by default options.
@Sarke Options are a bad thing _if they don't actually open up any new options_, as each choice we force users to make adds cognitive load. They also make template maintenance more complex. If static assets always compiled to root, then it would allow everyone to do what they want. Users could build out their desired folder structure inside of that folder.
@chrisvfritz After thinking about this again:
I don't know. I get the basic point that subdirectories make any 'target' directory possible, but:
index.html is in some subdirectory. So I would feel that most people would want to put static file into a subdirectory as well. /static/, but:/static/ would cover the default usecase (have static assets somewhere else, but not in root) _and_ enable people to change this location if they want to.I would feel that most people would want to put static file into a subdirectory as well.
@LinusBorg I'm not sure that assumption is correct - for example, I think most people prefer to have files like favicons in the root (and actually, that's where they should go). So it could even be argued any configuration except for copying to root would be "wrong", unless users are also configuring server-side redirects for paths like /favicon.ico.
@chrisvfritz One thing to consider is that static file sites like VueJS are getting more commonly hosted on CDN hosting, so redirects wouldn't be possible.
And the older shared hosting only allow redirects through an .htaccess, which would have to be in the root as well.
Good points ...
@Sarke Well, netlify and surge (two of the most popular services for static hosting) do actually support redirects, but yeah - it'd be easier for people to just be able to place a file somewhere and not have to configure anything (anywhere) to get it to go where they want.
S3 static website hosting doesn't support redirects. Would love to see either one of the proposed solutions implemented.
For us, the fix was as simple as setting assetsSubDirectory: './' in config/index.js.
@adambiggs S3 do support redirects
You can define redirect behavior on the object level or at bucket level
At object level:
https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
Basically you upload an empty file with "x-amz-website-redirect-location" set to the new location
At bucket level:
https://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html
Thanks for the info @heinzdmx, I wasn't aware of that. I think changing assetSubDirectory is an easier fix though.
I'd like to 1up this suggestion as well. I'm working in an app where client and server stuff live together in folders /client and /server. I'm trying to rearrange things so that they play together more nicely, and part of that is pulling the build processes and such out of client and into my project root.
But, if I pull out my webpack stuff into /, it only looks for static assets in /static, not /client/static, which means I have to make client and server stuff mingle.
Most helpful comment
@Sarke Options are a bad thing _if they don't actually open up any new options_, as each choice we force users to make adds cognitive load. They also make template maintenance more complex. If static assets always compiled to root, then it would allow everyone to do what they want. Users could build out their desired folder structure inside of that folder.