How to use the write function from gulp-sourcemaps
Find comprehensive JavaScript gulp-sourcemaps.write code examples handpicked from public code repositorys.
gulp-sourcemaps.write is a Gulp plugin that writes source map files to disk.
24 25 26 27 28 29 30 31 32 33 34
return gulp.src(wxssFileList, {cwd: srcPath, base: srcPath}) .pipe(gulpif(wxssConfig.less && wxssConfig.sourcemap, sourcemaps.init())) .pipe(gulpif(wxssConfig.less, less({paths: [srcPath]}))) .pipe(rename({extname: '.wxss'})) .pipe(gulpif(wxssConfig.less && wxssConfig.sourcemap, sourcemaps.write('./'))) .pipe(_.logger(wxssConfig.less ? 'generate' : undefined)) .pipe(gulp.dest(distPath)) }
GitHub: Dima0dev/MetamaskFork
497 498 499 500 501 502 503 504 505 506
.get('sourcemaps:write') // Use inline source maps for development due to Chrome DevTools bug // https://bugs.chromium.org/p/chromium/issues/detail?id=931675 .push( devMode ? sourcemaps.write() : sourcemaps.write('../sourcemaps', { addComment: false }), ); }); }
+ 25 other calls in file
How does gulp-sourcemaps.write work?
gulp-sourcemaps.write is a function in the Gulp pipeline that writes the sourcemap to a file or a stream based on the source file's destination. It takes an optional configuration object that allows you to specify the destination for the sourcemap file and other options. The sourcemap helps in debugging the minified or transpiled code by mapping it back to the original code.
76 77 78 79 80 81 82 83 84 85
`${src}/**/*.js` /* <-- then source globs */ ], { base: `./` }), sourcemaps.init(), closureCompiler(createClosureArgs(entry_point, externs)), // rename the sourcemaps from *.js.map files to *.min.js.map sourcemaps.write(`.`, { mapFile: (mapPath) => mapPath.replace(`.js.map`, `.${target}.min.js.map`) }), gulp.dest(out) ); } }))({});
+ 3 other calls in file
89 90 91 92 93 94 95 96 97 98
rename({ suffix: '.min' }) ) .pipe( sourcemaps.write('./') ) .pipe( dest(paths.css) );
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
const gulp = require("gulp"); const babel = require("gulp-babel"); const sourcemaps = require("gulp-sourcemaps"); function js() { return gulp .src("src/**/*.js") .pipe(sourcemaps.init()) .pipe(babel()) .pipe(sourcemaps.write(".")) .pipe(gulp.dest("dist")); } exports.js = js;
In this example, gulp-sourcemaps.write() is used to write the sourcemaps generated by the babel transpiler to the output directory specified in the gulp.dest() call.
GitHub: dynastina/biostudy
97 98 99 100 101 102 103 104 105 106
return lazypipe().pipe(function () { return gulpif(config.jsSourcemaps, sourcemaps.init({loadMaps: true, debug: config.debug})); }).pipe(function () { return gulpif(config.jsMinify, terser()); }).pipe(function () { return gulpif(config.jsSourcemaps, sourcemaps.write('./')); }); }, /**
+ 19 other calls in file
113 114 115 116 117 118 119 120 121 122
return src(paths.styles.src) .pipe(gulpif(!PRODUCTION, sourcemaps.init())) .pipe(sass().on('error', sass.logError)) .pipe(gulpif(PRODUCTION, postcss([ autoprefixer ]))) .pipe(gulpif(PRODUCTION, cleanCss({compatibility:'ie10'}))) .pipe(gulpif(!PRODUCTION, sourcemaps.write())) .pipe(dest(paths.styles.dest)) .pipe(server.stream()); } export const images = () => {
+ 13 other calls in file
GitHub: wuguokai/gpt_bot
45 46 47 48 49 50 51 52 53 54
return tsProject .src() .pipe(sourcemaps.init()) .pipe(tsProject()) .pipe( sourcemaps.write({ sourceRoot: file => { const sourceFile = path.join(file.cwd, 'src', file.sourceMap.file) return path.relative(path.dirname(sourceFile), file.cwd) }
+ 8 other calls in file
gulp-sourcemaps.write is the most popular function in gulp-sourcemaps (175 examples)