gajus / write-file-webpack-plugin

Forces webpack-dev-server to write bundle files to the file system.
Other
527 stars 54 forks source link

Plugin requires sudo on macOS and opens non default browser #65

Closed incompletude closed 6 years ago

incompletude commented 6 years ago

I'm not sure how to properly name this. I have been trying to use write file webpack plugin but I'm facing two problems on a macOS High Sierra and webpack-dev-server v3.1.4.

First, when using npm start (mapped to webpack-dev-server --mode development --open), adding the write plugin opens the Safari browser instead of the default browser.

Second, the plugin requires me to run sudo npm start, or it will throw an EACCESS error. This is not required by the standalone webpack.

gajus commented 6 years ago

Neither sound like something write-file-webpack-plugin would have an effect on.

Whats the path that EACCESS is complaining about?

CPatchane commented 6 years ago

Hi here, @gajus I have the same issue using the plugin. Here is the error message: Error: EACCES: permission denied, mkdir '/img'. Hope that helps!

incompletude commented 6 years ago

@gajus It was some weird interaction with clean-webpack-plugin: ^0.1.19. I think it is fixed for now.

CPatchane commented 6 years ago

But I have this issue without using the clean-webpack-plugin plugin :/

gajus commented 6 years ago

But I have this issue without using the clean-webpack-plugin plugin :/

I suggest trying to inspect the issue yourself.

It is very unlikely that it is originating from write-file-webpack-plugin. Even if the error points to write-file-webpack-plugin, it is likely some misconfiguration/ version incompatibility.

Looking at the error:

Error: EACCES: permission denied, mkdir '/img'

You are attempting to write something to /img directory, which you shouldn't have permission to write to unless you are root. Therefore the script is right to fail.

The question is why you are getting this error only with write-file-webpack-plugin (I am assuming you've tested without the plugin to ensure that the plugin is the culprit).

CPatchane commented 6 years ago

I never had this issue before. Now I am trying to write the build files when I use webpack-dev-server and it throws this issue (I just added this plugin). I will try to figure out in my code as soon as I have time.

CPatchane commented 6 years ago

It seems to be related to https://github.com/webpack-contrib/copy-webpack-plugin/issues/41

CPatchane commented 6 years ago

It seems to be related to webpack-contrib/copy-webpack-plugin#41

I confirm, this was due to a webpack loader using an outputPath beginning by /, we have to remove it (in my case it was file-loader with /img/ and now it works when I use img/).

I suppose, since write-file-webpack-plugin uses these paths to write files, this is why I got the error from this plugin. Maybe @gajus, it could be great to add some documentation about this case?

Thanks for your help 👍

gajus commented 6 years ago

Maybe @gajus, it could be great to add some documentation about this case?

Good idea. PR would be welcome.