Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working Visual Studio Code Debugger with vscode-chrome-debug sample #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ npm-debug.log
# IDE #
.idea/
*.swp

# VS Code
.vscode/chrome/
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000/",
"sourceMaps": true,
"diagnosticLogging": true,
"webRoot": "${workspaceRoot}/dist",
"userDataDir": "${workspaceRoot}/.vscode/chrome"
},
{
"name": "Attach Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"diagnosticLogging": true,
"webRoot": "${workspaceRoot}/dist"
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1",
"webpack-md5-hash": "^0.0.5"
"webpack-md5-hash": "^0.0.5",
"write-file-webpack-plugin": "^3.1.8"
},
"repository": {
"type": "git",
Expand Down
39 changes: 35 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var helpers = require('./helpers');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
var WriteFilePlugin = require('write-file-webpack-plugin');

/**
* Webpack Constants
Expand Down Expand Up @@ -47,7 +48,8 @@ module.exports = {
//
// See: http://webpack.github.io/docs/configuration.html#devtool
// See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
devtool: 'cheap-module-eval-source-map',
// Note: Changed from 'eval' to 'inline' for Visual Studio Code Debugger
devtool: 'cheap-module-inline-source-map',

// Cache generated modules and chunks to improve performance for multiple incremental builds.
// This is enabled by default in watch mode.
Expand Down Expand Up @@ -106,8 +108,27 @@ module.exports = {
// inside the output.path directory.
//
// See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
chunkFilename: '[id].chunk.js'
chunkFilename: '[id].chunk.js',

// Filename template string of function for the sources
// array in a generated SourceMap.
//
// See: http://webpack.github.io/docs/configuration.html#output-devtoolmodulefilenametemplate
devtoolModuleFilenameTemplate: function (info) {
var resourcePath = info.absoluteResourcePath;
if (resourcePath.indexOf(__dirname) !== 0) {
// Normalize resouce path if it is not an absolute path
// (e.g. 'node_modules/rxjs/Observable.js')
resourcePath = helpers.root(resourcePath);
}
if (resourcePath.charAt(0) === '/') {
// Mac OS X absolute path has a leading slash already
// https://github.com/Microsoft/vscode-chrome-debug/issues/63#issuecomment-163524778
return 'file://' + resourcePath;
} else {
return 'file:///' + resourcePath;
}
}
},

// Options affecting the normal modules.
Expand Down Expand Up @@ -218,8 +239,17 @@ module.exports = {
//
// See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
// NOTE: when adding more properties make sure you include them in custom-typings.d.ts
new webpack.DefinePlugin({'ENV': JSON.stringify(METADATA.ENV), 'HMR': HMR})
new webpack.DefinePlugin({'ENV': JSON.stringify(METADATA.ENV), 'HMR': HMR}),

// Plugin: Write File Plugin
// Description: Write bundle files for debugging.
// Forces webpack-dev-server program to write bundle files to the file system.
//
// For use in conjuction with Visual Code debugger.
//
// See: https://github.com/AngularClass/angular2-webpack-starter/issues/297#issuecomment-193989148
// See: https://github.com/gajus/write-file-webpack-plugin
new WriteFilePlugin()
],

// Static analysis linter for TypeScript advanced options configuration
Expand All @@ -245,7 +275,8 @@ module.exports = {
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
},
outputPath: helpers.root('dist')
},

// Include polyfills or mocks for various node stuff
Expand Down