Skip to content
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

Upload Triggers too Early in Build Process #130

Open
sinemacula opened this issue Jan 16, 2020 · 10 comments
Open

Upload Triggers too Early in Build Process #130

sinemacula opened this issue Jan 16, 2020 · 10 comments

Comments

@sinemacula
Copy link
Contributor

OS: Windows, Mac, and Linux
Node: 10.16.3
NPM: 6.11.2
Webpack: 4.41.2
s3-webpack-plugin: 1.0.3

The Issue

Certain assets are excluded from the upload manifest due to the moment at which the S3 plugin triggers.

There are various examples I can give so I will highlight a few:

  • Assets copied during the build process without using webpack e.g. Laravel Mix
  • Assets compiled with mix.scripts, mix.styles and mix.babel when using Laravel Mix
  • Assets manually generated after the build process e.g. merged CSS files

I managed to find someone else with the same issue: https://stackoverflow.com/questions/57380123/laravel-mix-versioning-when-uploaded-in-s3-thinks-in-previous-hash

I do not believe this is limited to only those that use Laravel Mix. I assume that it is also relevant to those that manipulate their files during the webpack build process, but without using webpack to do it (i.e. it is not in the buid manifest).

I believe that the issue lies here:

compiler.hooks.afterEmit.tapPromise(packageJson.name, async(compilation) => {

Potential Solution

I am not overly familiar with webpack plugins so I can't be certain this will not break other parts of the plugin but I tried the following and it seemed to fix the issue:

compiler.hooks.done.tapPromise(packageJson.name, async(compilation) => {

I will also create a pull request.

@sinemacula
Copy link
Contributor Author

I forgot to say, if you need any additional information, or more non-Laravel Mix examples then let me know and I can expand further, and give some code examples. I wanted to keep the description brief in the first instance.

@MikaAK
Copy link
Owner

MikaAK commented Jan 17, 2020

You can fix this by using the directory parameter to specify the build directory. Unfortunately, I don't think making changes to suit larvel is a good idea!

@sinemacula
Copy link
Contributor Author

Thank you for your prompt response.

As mentioned, this is not relevant to just those using Laravel Mix, it just so happens that the examples I have provided are related to it.

I tested out every available parameter and option before posting as I wanted to ensure I had tried everything. Not to mention, my implementation is already using the directory parameter.

Surely just updating the event to trigger once the compilation is complete is a good thing to do regardless?

@MikaAK
Copy link
Owner

MikaAK commented Jan 17, 2020

Awesome, thanks for more info. I've merged it in and will draft a release tonight 😄
Thanks for your work 🙏

@sinemacula
Copy link
Contributor Author

Thank you so much!!! :-D

@sinemacula
Copy link
Contributor Author

Hi Mika,

Any update on the release? I can see the build is failing, is there anything I can help with?

@sinemacula sinemacula reopened this Jan 20, 2020
@MikaAK
Copy link
Owner

MikaAK commented Jan 30, 2020

The tests are failing and I'm not sure why, I was inclined to think it a config on aws issue but some fail others don't, gonna try reverting and testing, if it doesn't fail we'll need to fix tests before launching this

@sinemacula
Copy link
Contributor Author

Okay, thanks Mika, keep me updated :-D

@caseybienvenu
Copy link

I am also experiencing a similar problem. I have one JS file generated using mix.scripts that does not get transferred to S3 the first time the S3 plugin runs. Other files are transferred properly.

Interestingly, when I run a 2nd time, that missing JS file is transferred properly.

Also using s3-webpack-plugin version 1.0.3.

@selected-pixel-jameson
Copy link

Also having the exact same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants