7

I'm running a node.js webapp using javascript and webpack which I built following this guide. I've installed the chrome debugger extension.

I run the node server using the command:

webpack-dev-server --progress --colors 

I've also run webpack --devtool source-map

My launch config looks like this:

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "http://localhost:8080", "webRoot": "${workspaceFolder}" } ] } 

After running webpack-dev-server --progress --colors and hitting F5 in VSCode Chrome loads up with the webpage, all my breakpoints appear solid red but when placed they jump a bit lower from where I placed them (including on lines which are executing code). The breakpoints also don't hit which makes me believe there's something wrong with the debug mapping. When I have breakpoints placed on occasion random files get loaded and invisible breakpoints in them are hit, like in node_modules/firebase/index.js an invisible breakpoint over a commented out line is hit.

I should also note running .scripts in vscode does yield (amongst all the modules) my entry.js file which I'm trying to hit breakpoints in, namely: -webpack:///./entry.js (d:\myproject\entry.js)

Everything is placed in the root of my directories (screenshot in case I make a mistake transposing the directories);

enter image description here

Also my webpack.config.js file:

module.exports = { entry: "./entry.js", output: { path: __dirname, filename: "bundle.js" }, module: { loaders: [ { test: /\.css$/, loader: "style-loader!css-loader" } ] } }; 
11
  • could you please show the root directory structure, such as where the bundled files are being placed? Commented Dec 27, 2017 at 4:43
  • @AjayGupta I just attached a pic of the root directory folder, let me know if that's what you wanted to see :) Commented Dec 27, 2017 at 4:45
  • So Build is where all the bundled assets go? Commented Dec 27, 2017 at 4:46
  • @AjayGupta oh no that's not the case, Build is a folder with Unity project files. Perhaps I don't quite understand how webpack works, is there a build directory that everything should be written to? I thought the webpack file was built into my bundle.js file: module.exports = { entry: "./entry.js", output: { path: __dirname, filename: "bundle.js" }, module: { loaders: [ { test: /\.css$/, loader: "style-loader!css-loader" } ] } }; Commented Dec 27, 2017 at 4:47
  • oh sorry, i didn't look closely for the bundle.js file.. Anyways, where exactly are you placing the breakpoints? for example on a line with just { or things like that? Commented Dec 27, 2017 at 4:50

1 Answer 1

8

Problem solved!

Needed to add:

 devtool: 'inline-source-map' 

To my webpack.config.js module.exports. Now breakpoints hit inline on functions everywhere.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.