Closed knicklabs closed 6 years ago
@knicklabs in https://github.com/gobuffalo/buffalo/commit/96baaab5baeff7dc7c5874c4f5447242c98bf259#diff-53399b34c7dfc25ab7dfa0b83d30ce8epack.config.js.tmpl there was added clean-webpack-plugin
that will take care of the assets cleanup, as far as I can tell this should be covered with that enhancement.
@paganotoni Fantastic! Apologies for not spotting that. I'm brand new to the community. Been using Buffalo for all of a couple days.
The only issue I see with that is that it's only cleaning the compiled JS and CSS. However, you can add other files to assets
and they will be copied over to public/assets
as configured here.
Forgive me please if I'm missing something, but because public/assets
is an output directory, I avoid writing it to it. Seems that it should be best practice to put all assets, e.g. images, favicons, etc. into assets
and let webpack copy it to public/assets
. In such a case, shouldn't the entire directory be cleaned?
@knicklabs that makes sense, we should clean those images and other files to avoid having them into the compiled binary as well as making trash there. thanks for putting together a great description with this issue, sorry that i didn't spot that detail from it.
if you want to work on this, PR's are always welcome, otherwise i can help if needed. Thanks Again!
Thanks @paganotoni. I've taken a stab at addressing the issue.
Awesome! I did just read the PR, thanks!
closed by #728
Expected Behavior
The
public/assets
directory is the output directory for compiled assets and other assets copied from theassets
directory.It is a best practice to clean the output directory before build. This ensures that only the files actually in use by the project are in the directory.
I would expect the following:
public/assets/manifest.json
and any files that exist inassets
that are not part of the webpack bundle, such as image files that have been included because they are referenced directly in Plush template files.Actual Behavior
The output directory is not cleaned before build. This results in the following:
assets
directory permanently remain in the output directory.public/assets/manifest.json
permanently remain in the output directory.public/assets
directory is included in the built binary, as can be inspecting by ejecting the assets on build.Here is an example of what my
public/assets
directory looks like after a couple days of development.And here is an example of what is bundled in the ejected assets when building for production.