2017-08-01 54 views
1

的一部分,我知道我可以通過創建一個JavaScript Debug配置和定位,在我跑步的應用程序調試純在WebStorm反應的應用程序。調試反應的web應用程序是DOTNET

我得到的只是一個簡單的工作是反應在得到WebStorm(File -> New -> Project -> React App

創建樣板應用程序,但我有一個現有的項目,有一個DOTNET後端,並在同一個項目一個陣營前端。樹看起來像

MyApp 
    - src 
    - Controllers 
    - Models 
    ... 
    - UIApp 
     - src 
     ... (react ui parts) 
    .... 

我的第一包裝的一切連同npm run distdev運行該項目,然後dotnet run -f net47開始一切。但我無法弄清楚如何調試js。

我在WebStorm中再次創建了一個JavaScript Debug COnfiguration,並將其指向該URL(localohst:3000)。在Debug窗口中的Console選項卡中,我可以看到控制檯正在工作,但沒有發生斷點。

是我想要做的可能嗎?還是我只是有調試堅持在Source標籤在Chrome

packaage.json

{ 
    "name": "myapp", 
    "version": "0.0.1", 
    "description": "my appn", 
    "repository": "", 
    "main": "dist/js/app.js", 
    "dependencies": { 
    "axios": "0.16.2", 
    "babel-polyfill": "6.23.0", 
    "es6-promise": "4.1.1", 
    "halogen": "^0.2.0", 
    "history": "4.6.3", 
    "immutable": "3.8.1", 
    "material-ui": "0.18.6", 
    "moment": "2.18.1", 
    "query-string": "^4.3.4", 
    "react": "15.6.1", 
    "react-addons-css-transition-group": "15.6.0", 
    "react-addons-update": "15.6.0", 
    "react-bootstrap": "0.31.0", 
    "react-bootstrap-table": "4.0.0-beta.1", 
    "react-datepicker": "0.44.0", 
    "react-datetime": "2.8.4", 
    "react-dnd": "2.4.0", 
    "react-dnd-html5-backend": "2.1.2", 
    "react-dom": "15.6.1", 
    "react-dropzone-component": "2.0.0", 
    "react-proxy": "1.1.8", 
    "react-redux": "5.0.5", 
    "react-redux-toastr": "7.0.0", 
    "react-router": "4.1.1", 
    "react-router-bootstrap": "0.24.2", 
    "react-router-dom": "4.1.1", 
    "react-router-redux": "5.0.0-alpha.6", 
    "react-s-alert": "1.3.0", 
    "react-svg-piechart": "1.3.0", 
    "react-tap-event-plugin": "2.0.1", 
    "react-tinymce": "^0.5.1", 
    "react-widgets": "4.0.0-rc.15", 
    "redux": "3.7.1", 
    "redux-auth-wrapper": "^1.1.0", 
    "redux-form": "6.8.0", 
    "redux-immutablejs": "0.0.8", 
    "redux-promise": "0.5.3", 
    "redux-throttle": "0.1.1", 
    "redux-thunk": "2.2.0", 
    "redux-tooltip": "0.7.2", 
    "rest-url-builder": "1.0.6" 
    }, 
    "devDependencies": { 
    "babel-core": "6.25.0", 
    "babel-eslint": "7.2.3", 
    "babel-plugin-transform-object-rest-spread": "6.23.0", 
    "babel-plugin-transform-object-assign": "6.22.0", 
    "babel-plugin-transform-es2015-object-super": "6.24.1", 
    "babel-plugin-transform-es2015-arrow-functions": "6.22.0", 
    "babel-plugin-transform-es2015-for-of": "6.23.0", 
    "babel-preset-es2015": "6.24.1", 
    "babel-preset-react": "6.24.1", 
    "babel-plugin-react-transform": "2.0.2", 
    "babelify": "7.3.0", 
    "browserify": "14.4.0", 
    "del": "3.0.0", 
    "envify": "4.1.0", 
    "eslint-plugin-react": "7.1.0", 
    "gulp": "3.9.1", 
    "gulp-babel": "6.1.2", 
    "gulp-clean-css": "3.6.0", 
    "gulp-concat-css": "2.3.0", 
    "gulp-eslint": "4.0.0", 
    "gulp-flatten": "0.3.1", 
    "gulp-header": "1.8.8", 
    "gulp-if": "2.0.2", 
    "gulp-rename": "1.2.2", 
    "gulp-sass": "3.1.0", 
    "gulp-sourcemaps": "2.6.0", 
    "gulp-uglify": "3.0.0", 
    "gulp-util": "3.0.8", 
    "livereactload": "3.3.0", 
    "reactify": "1.1.1", 
    "uglify-js": "3.0.24", 
    "vinyl-buffer": "1.0.0", 
    "vinyl-source-stream": "1.1.0", 
    "watchify": "3.9.0", 
    "webpack": "3.1.0", 
    "webpack-stream": "3.2.0" 
    }, 
    "scripts": { 
    "clean": "gulp clean", 
    "lint": "gulp lint", 
    "distdev": "gulp distUI-dev", 
    "dist": "gulp distUI", 
    "watch": "gulp default" 
    }, 
    "browserify": { 
    "transform": [ 
     "reactify", 
     "envify" 
    ] 
    } 
} 

gulpfile.babel.js

import gulp from 'gulp'; 
import babelify from 'babelify'; 
import browserify from 'browserify'; 
import del from 'del' 
import eslint from 'gulp-eslint'; 
import gulpif from 'gulp-if'; 
import sass from 'gulp-sass'; 
import uglify from 'gulp-uglify'; 
import buffer from 'vinyl-buffer'; 
import source from 'vinyl-source-stream'; 
import sourcemaps from 'gulp-sourcemaps'; 
import cleanCSS from 'gulp-clean-css'; 
import concatCss from 'gulp-concat-css'; 

const paths = { 
    appBundle: 'appBundle.js', 
    appBundleMin: 'appBundle.min.js', 
    srcMain: 'UIApp/src/js/Main.js', 
    srcSassMain: 'UIApp/src/styles/app.scss', 
    srcLint: ['UIApp/src/**/*.js', 'UIApp/test/**/*.js'], 
    srcDocuments:['UIApp/src/documents/*'], 
    dist: 'wwwroot', 
    distJs: 'wwwroot/js', 
    distCss: 'wwwroot/css', 
    appDistCss:'wwwroot/css/app.css', 
    distFonts: 'wwwroot/fonts', 
    distFontAwesome: 'wwwroot/fonts/font-awesome', 
    distImages: 'wwwroot/images', 
    distDocuments: 'wwwroot/documents' 
}; 

var debug = true 

gulp.task('styles', function() { 
    gulp.src(paths.srcSassMain) 
    .pipe(sourcemaps.init({loadMaps: true})) 
    .pipe(sass().on('error', sass.logError)) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest(paths.distCss)); 
}); 

gulp.task('stylesminify', function() { 
    gulp.src(paths.srcSassMain) 
    .pipe(sourcemaps.init({loadMaps: true})) 
    .pipe(sass().on('error', sass.logError)) 
    .pipe(concatCss('app.min.css')) 
    .pipe(buffer()) 
    .pipe(cleanCSS({debug: debug, processImport: false}, function(details) { 
    })) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest(paths.distCss)) 
}); 

gulp.task('browserify',() => { 
    browserify(paths.srcMain, {debug: true}) 
    .transform(babelify) 
    .bundle() 
    .pipe(source(paths.appBundle)) 
    .pipe(buffer()) 
    .pipe(sourcemaps.init({loadMaps: true})) 
    .pipe(gulpif(!debug, uglify())) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest(paths.distJs)); 
}); 

gulp.task('appuglify',() => { 
    browserify(paths.srcMain, {debug: true}) 
    .transform(babelify) 
    .bundle() 
    .pipe(source(paths.appBundleMin)) 
    .pipe(buffer()) 
    .pipe(sourcemaps.init({loadMaps: true})) 
    .pipe(uglify()) 
    .pipe(sourcemaps.write('.')) 
    .pipe(gulp.dest(paths.distJs)); 
}); 

gulp.task('copyFiles', function() { 
    // copy css files 
    gulp.src('UIApp/src/styles/**/*.css') 
    .pipe(gulp.dest(paths.distCss)); 
    // copy images 
    gulp.src('UIApp/src/images/**/*') 
    .pipe(gulp.dest(paths.distImages)); 
    //copy documents 
    gulp.src('UIApp/src/documents/**/*') 
    .pipe(gulp.dest(paths.distDocuments)); 
    // copy Fonts 
    gulp.src('UIApp/src/fonts/**/*') 
    .pipe(gulp.dest(paths.distFonts)); 
    // copy Font Awesome 
    gulp.src('UIApp/src/font-awesome/**/*') 
    .pipe(gulp.dest(paths.distFontAwesome)); 
    gulp.src('UIApp/src/js/common/**/*') 
     .pipe(gulp.dest(paths.distJs)); 
}); 

gulp.task('lint',() => { 
    gulp.src(paths.srcLint) 
    .pipe(eslint()) 
    .pipe(eslint.format()); 
}); 

gulp.task('distUI-dev', [ 
    'browserify', 'styles', 'copyFiles' 
]); 

gulp.task('distUI', [ 
    'appuglify', 'stylesminify', 'copyFiles' 
]); 

gulp.task('clean', function() { 
    return del([paths.dist]); 
}); 

gulp.task('watch',() => { 
    gulp.watch(paths.srcLint, ['distUI-dev']); 
}); 

gulp.task('default', ['watch', 'distUI']); 
+0

請您分享您的package.json和配置的WebPack? –

+0

像這樣的調試只能用於webpack嗎?我用一口捆綁,這可能是問題,那麼 – John

+0

不僅與的WebPack,而是取決於你的配置,也許你需要爲了添加源地圖使用Chrome瀏覽器開發工具 –

回答

1
在咕嘟咕嘟文件

,在任務browserify ,嘗試在uglify之後應用源映射。看看這裏: https://github.com/gulpjs/gulp/blob/master/docs/recipes/browserify-uglify-sourcemap.md

我認爲這會爲您提供正確的源地圖,以便您在代碼中進行調試。

你可以寫調試;聲明在您的代碼爲了停止流程。

+0

對不起,我不太瞭解。這看起來像我已經在browserify任務 – John

+1

你能夠使用調試器進行調試;聲明? (即使不是原始代碼) –

+0

是的,如果我有'調試器;'在我的代碼中它停在IDE中。雖然它關閉了幾行 – John