From 29fb9c742eabfeab309064ebf4704982c63c1aad Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Fri, 12 Jan 2018 17:24:07 +0800 Subject: [PATCH] Added: debug options for vscode debug --- .vscode/launch.json | 22 +++++++++++++++++++++- package.json | 1 + src/main/index.dev.js | 11 +++++++++++ src/main/index.js | 4 ++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 08cf306..3f122b7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,14 +4,34 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Launch", + "type": "node", + "request": "launch", + "program": "${workspaceRoot}/src/main/index.dev.js", + "env": { + "DEBUG_ENV": "debug" + }, + "stopOnEntry": false, + "args": [], + "cwd": "${workspaceRoot}", + // this points to the electron task runner + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "runtimeArgs": [ + "--nolazy" + ], + "sourceMaps": true + }, { "name": "Attach", "type": "node", "request": "attach", "port": 5858, - "sourceMaps": false, + "sourceMaps": true, + "restart": true, "outFiles": [], "localRoot": "${workspaceRoot}", + "protocol": "inspector", "remoteRoot": null } ] diff --git a/package.json b/package.json index aa84d2d..742d8d9 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "license": "MIT", "main": "./dist/electron/main.js", "scripts": { + "render": "webpack-dev-server --hot --colors --config .electron-vue/webpack.renderer.config.js --port 9080 --content-base app/dist", "build": "node .electron-vue/build.js && electron-builder", "release": "node .electron-vue/build.js && electron-builder", "build:dir": "node .electron-vue/build.js && electron-builder --dir", diff --git a/src/main/index.dev.js b/src/main/index.dev.js index e38a165..ab105f9 100644 --- a/src/main/index.dev.js +++ b/src/main/index.dev.js @@ -24,4 +24,15 @@ require('electron').app.on('ready', () => { }) // Require `main` process to boot app +if (process.env.DEBUG_ENV === 'debug') { + require('babel-core/register')({ + 'presets': [ + ['env', { + 'targets': { + 'node': true + } + }] + ] + }) +} require('./index') diff --git a/src/main/index.js b/src/main/index.js index 3c8bbc4..2c834df 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -13,6 +13,9 @@ import pkg from '../../package.json' if (process.env.NODE_ENV !== 'development') { global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') } +if (process.env.DEBUG_ENV === 'debug') { + global.__static = require('path').join(__dirname, '../../static').replace(/\\/g, '\\\\') +} let window let settingWindow @@ -50,6 +53,7 @@ function createTray () { { label: '打开详细窗口', click () { + console.log(1) if (settingWindow === null) { createSettingWindow() settingWindow.show()