国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - gulp-babel后的代碼uglify后,sourcemaps定位不準(zhǔn)

瀏覽:96日期:2023-09-10 11:22:41

問題描述

有如下ES6代碼

let that = this;let DOMp = document.querySelectorAll(’p’);let DOMpArray = Array.prototype.slice.call(DOMp);console.log(DOMpArray);class Modal { constructor() {console.log(’what’);this.init(); } init() { }}new Modal();

和如下gulp代碼

const uglify = require(’gulp-uglify’);const babel = require(’gulp-babel’);const sourcemaps = require(’gulp-sourcemaps’);const plumber = require(’gulp-plumber’);const chalk = require(’chalk’);gulp.task(’js’, function () { console.log(chalk.yellow(’[進(jìn)行中] js(!entry_*.js ES6->ES5)’)); return gulp.src(’dev/js/test.js’).pipe(plumber()).pipe(sourcemaps.init()).pipe(babel()).pipe(uglify()).pipe(sourcemaps.write(’./maps’)).pipe(gulp.dest(`./static/js/`)).on(’end’, function () { console.log(chalk.green(’[已完成] js(!entry_*.js ES6->ES5)’));});});

瀏覽器執(zhí)行生成的js輸出到控制臺(tái)的內(nèi)容,點(diǎn)擊文件定位到的代碼行不對(duì)。是我用法有問題嗎?

問題解答

回答1:

位置錯(cuò)了。

const uglify = require(’gulp-uglify’);const babel = require(’gulp-babel’);const sourcemaps = require(’gulp-sourcemaps’);const plumber = require(’gulp-plumber’);const chalk = require(’chalk’);gulp.task(’js’, function () { console.log(chalk.yellow(’[進(jìn)行中] js(!entry_*.js ES6->ES5)’)); return gulp.src(’dev/js/test.js’).pipe(sourcemaps.init()) // <------ 這里.pipe(plumber()) // <------ 這里.pipe(babel()).pipe(uglify()).pipe(sourcemaps.write(’./maps’)).pipe(gulp.dest(`./static/js/`)).on(’end’, function () { console.log(chalk.green(’[已完成] js(!entry_*.js ES6->ES5)’));});});

參考:

https://stackoverflow.com/que...

https://fettblog.eu/gulp-4-so...

標(biāo)簽: JavaScript
主站蜘蛛池模板: 北京市| 桃园市| 浪卡子县| 定州市| 南和县| 谷城县| 郧西县| 华容县| 石台县| 嫩江县| 金门县| 汶上县| 吕梁市| 祥云县| 乐清市| 红安县| 贵州省| 永顺县| 广安市| 盐山县| 土默特右旗| 松潘县| 行唐县| 辛集市| 醴陵市| 临清市| 清河县| 扎囊县| 定陶县| 正安县| 新安县| 昌图县| 富源县| 隆化县| 灵山县| 玉龙| 磐石市| 南和县| 桐柏县| 穆棱市| 孝感市|