Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring VSC's launch.json to launch webpack-dev-server

I am trying to get Visual Studio Code to launch webpack's "webpack-dev-server" command, but no matter what configuration I use in launch.json I get an error.

My current launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "./node_modules/.bin/webpack-dev-server.cmd",
            "stopOnEntry": false,
            "args": ["-d --hot --inline"],
            "cwd": ".",
            "runtimeExecutable": null,
            "runtimeArgs": [],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": true,
            "outDir": "null"
        },
        {
            "name": "Attach",
            "type": "node",
            "request": "attach",
            "port": 5858
        }
    ]
}

Current error is:

cannot launch program 'c:\ftct\node_modules\.bin\webpack-dev-server.cmd'; setting the 'outDir' attribute might help

I have tried setting the outDir to some value or other, but it complains about setting this attribute nonetheless.

Any ideas? This is what feels like the final hurdle in my migrating from Visual Studio 2015 to Visual Studio Code!

like image 987
serlingpa Avatar asked Dec 09 '15 16:12

serlingpa


1 Answers

Anyone running into this, I was able to get it to work with this:

{
    "type": "node",
    "request": "launch",
    "name": "Start JS",
    "program": "${workspaceFolder}/node_modules/webpack-dev-server/bin/webpack-dev-server",
    "args": [
        "--config",
        "webpack.javascript.js",
        "--hot",
        "--progress"
    ],
    "console": "internalConsole",
    "internalConsoleOptions": "openOnSessionStart"
},

This is using a custom webpack.javascript.js config file. If you use the default you can probably remove the first two args. Formatting is a little message in the console on start but it works including hitting breakpoints.

This is in the latest VS Code at the time of this writing.

like image 53
Ernie S Avatar answered Nov 14 '22 23:11

Ernie S