mariusbalcytis / webpack-bundle

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

Running webpack dev server on different host or port #3

Closed skimi closed 8 years ago

skimi commented 8 years ago

I'm passing --port & --host in the bundle config for the webpack-dev-server. It's great, it works, the command executed by "app/console maba:webpack:dev-server" has those arguments but in the end the server still runs on localhost:8080.

When executing the command generated by "app/console maba:webpack:dev-server" manually it works fine. Webpack runs on the specified port and host. But when running through the symfony command it's stuck on http://localhost:8080.

Running on different port or host is useful because development server are not always run from localhost.

Help

config:

maba_webpack:
    config:
        parameters: { public_path: http://mysuperdomain.com:9999/compiled/ }
    bin:
        dev_server:
            arguments:
                - --hot
                - --history-api-fallback
                - --inline
                - --host 0.0.0.0
                - --port 9999
skimi commented 8 years ago

So I figured out the problem and it has nothing to do with this bundle. The bundle uses a ProcessBuilder class which in turn return a Process object through its getProcess() method.

The problem is that the getProcess method passes all arguments to an argument escaping function ProcessUtils::escapeArguments which basicly adds quotes around all arguments.

My command ended looking like this :

'node' 'node_modules/webpack-dev-server/bin/webpack-dev-server.js' '--config "/home/rgebski/vanao/app/cache/dev/webpack.config.js"' '--hot' '--history-api-fallback' '--inline' '--host 0.0.0.0' '--port 9999'

Quotes around everything that make '--host 0.0.0.0' '--port 9999' not working. What works is '--host' '0.0.0.0' '--port' '9999'.

So my config now lools like this :

maba_webpack:
    config:
        parameters: { public_path: http://mysuperdomain.com:9999/compiled/ }
    bin:
        dev_server:
            arguments:
                - --hot
                - --history-api-fallback
                - --inline
                - --host
                - '0.0.0.0'
                - --port
                - '9999'