mariusbalcytis / webpack-bundle

Bundle to Integrate Webpack into Symfony
MIT License
122 stars 36 forks source link

Dev-server on Windows #10

Closed maryo closed 8 years ago

maryo commented 8 years ago

I am running on Windows and when I try to run the maba:webpack:dev-server command then I get '"exec"' is not recognized as an internal or external command, operable program or batch file. message.

So I've temporarily commented out line 76 inside src/Compiler/WebpackCompiler.php - // array('exec'), which fixed it. I'd sent a PR but since I'm not a Linux expert I'm not sure why exactly the exec is present. Could it be removed? Or should there be a condition for OS? Which solution do you prefer? Or another one?

EDIT: Another workarround without editing vendor code is to shim exec command by creating exec.cmd file inside the project root containing @%*.

Thanks for this great bundle.

mariusbalcytis commented 8 years ago

It's there so that stop would work on linux. See note in Symfony documentation - php wraps command in separate sh process, so when stop is called, it stops that sh process and node (dev-server) process is still running in the background. Another cannot be started as port is already taken.

I haven't found any information about what's the case in Windows for that separate sh process.

One solution could be just to avoid exec on windows machines, but it could still leave processes in the background, which would not be nice. Could you check this on your machine:

  1. Comment out that line (exec)
  2. Start dev-server command
  3. Change twig template - add, change or remove entry point in your twig template (while command is still running)
  4. Command restarts automatically to handle new entry point(s)
  5. What's the situation now? Is first node process stopped and second started successfully?

Thanks.

Another way to deal would be just ignoring changes in twig files - they are not changed so frequently and when configuration is changed (like config.yml), command still needs manual restart, so this does not handle all the cases.

maryo commented 8 years ago

OK. I see. I've tried it and looks like it works. From the Symfony doc: POSIX signals are not available on Windows platforms, please refer to the PHP documentation for available signals. Symfony handles stopping of the process differently on Windows. Check this line https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Process/Process.php#L1522

PR sent

mariusbalcytis commented 8 years ago

Fixed by #14. Thanks!