How to use the src function from gulp
Find comprehensive JavaScript gulp.src code examples handpicked from public code repositorys.
152 153 154 155 156 157 158 159 160 161
gulp.task('sample-templates', function(){ var opts = { root: 'partials', module: 'sample' }; return gulp.src('sample/partials/*.html') .pipe($.minifyHtml(minifyHtmlOptions)) .pipe($.angularTemplatecache('samples.js', opts)) .pipe(gulp.dest('.tmp')); });
446
950
96
+ 27 other calls in file
GitHub: donspablo/zombie
21 22 23 24 25 26 27 28 29 30
return del('lib/**'); } function build() { return gulp.src('src/**/*.js') .pipe(sourcemaps.init()) .pipe(babel()) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('lib'))
558
2
0
+ 5 other calls in file
14 15 16 17 18 19 20 21 22 23
var plugin1 = require('gulp-plugin1'); var plugin2 = require('gulp-plugin2'); var sourcemaps = require('gulp-sourcemaps'); gulp.task('javascript', function() { gulp.src('src/**/*.js') .pipe(sourcemaps.init()) .pipe(plugin1()) .pipe(plugin2()) .pipe(sourcemaps.write())
1
1
3
+ 53 other calls in file
31 32 33 34 35 36 37 38 39 40
}))) .pipe(tslint.report()); }); gulp.task('compile:src', function (done) { gulp.src([ config.paths.project.root + '/src/**/*.sql', config.paths.project.root + '/src/**/*.svg', config.paths.project.root + '/src/**/*.html' ]).pipe(gulp.dest('out/src/'));
869
0
1
+ 9 other calls in file
GitHub: dabeng/OrgChart
50 51 52 53 54 55 56 57 58 59
'node_modules/jspdf/dist/jspdf.umd.min.js', 'node_modules/json-digger/dist/json-digger.js' ]) .pipe(gulp.dest(paths.demoJSFolder)); var cssFiles = gulp.src(paths.srcCSS) .pipe(gulp.dest(paths.demoCSSFolder)); return merge(jsFiles, cssFiles); }));
758
0
150
+ 17 other calls in file
GitHub: vigetlabs/blendid
45 46 47 48 49 50 51 52 53 54
} } TASK_CONFIG.stylesheets.configured = true return gulp.src(paths.src) .pipe(gulpif(!global.production, sourcemaps.init())) .pipe(gulpif(preprocess, sass(TASK_CONFIG.stylesheets.sass))) .on('error', handleErrors) .pipe(postcss(TASK_CONFIG.stylesheets.postcss.plugins, TASK_CONFIG.stylesheets.postcss.options))
712
0
149
+ 3 other calls in file
292 293 294 295 296 297 298 299 300 301
blocklyDemoConfig.pageRoot = `${baseDir}/${exampleDir}`; const pageRegex = /.*\.(html|htm|md)$/i; const pages = blocklyDemoConfig.files.filter((f) => pageRegex.test(f)); const assets = blocklyDemoConfig.files.filter((f) => !pageRegex.test(f)); let stream = gulp.src( pages.map((f) => path.join(baseDir, exampleDir, f)), {base: baseDir, allowEmpty: true}) .pipe(gulp.header(buildFrontMatter(blocklyDemoConfig))); if (assets.length) {
468
632
0
24 25 26 27 28 29 30 31 32 33
gulp.task('watch', function() { gulp.watch(Paths.SCSS, gulp.series('compile-scss')); }); gulp.task('open', function() { gulp.src('index.html') .pipe(open()); }); gulp.task('open-app', gulp.parallel('open', 'watch'));
449
0
45
+ 7 other calls in file
61 62 63 64 65 66 67 68 69 70
For example: ```javascript gulp.task('sass', function () { return gulp.src('./sass/**/*.scss') .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) .pipe(gulp.dest('./css')); }); ```
391
0
2
+ 19 other calls in file
64 65 66 67 68 69 70 71 72 73
// 压缩 css 文件 // 在命令行使用 gulp css 启动此任务 gulp.task('css', function () { // 1. 找到文件 return gulp.src('css/*.css') // 2. 压缩文件 .pipe(minifyCSS()) // 3. 另存为压缩文件 .pipe(gulp.dest('dist/css'))
372
0
354
+ 11 other calls in file
166 167 168 169 170 171 172 173 174
```js var uglify = require('gulp-uglify') gulp.task('uglifyjs', function () { gulp.src('src/js/**/*.js') .pipe(uglify()) .pipe(gulp.dest('dist/js')) })
372
0
354
+ 5 other calls in file
GitHub: sarcadass/granim.js
63 64 65 66 67 68 69 70 71 72
.pipe(rename('script.js')) .pipe(gulp.dest('./docs/assets/js/')); }); gulp.task('buildDoc:css', function() { return gulp.src('./docs/assets/css/scss/index.scss') .pipe(gulpif(isSourcemaps, sourcemaps.init({ loadMaps: true }))) .pipe(sass({ outputStyle: 'compressed' }) .on('error', sass.logError) )
262
0
95
+ 19 other calls in file
GitHub: imcvampire/vue-axios
61 62 63 64 65 66 67 68 69 70
} return stream; }) gulp.task('clean', function () { return gulp.src('dist/*').pipe( clean({ force: true, }), )
187
0
43
+ 7 other calls in file
GitHub: mobi-css/mobi.css
65 66 67 68 69 70 71 72 73 74
} const distDir = path.dirname(dist); const distBasename = path.basename(dist); gulp.src(src) .pipe(sourcemaps.init()) .pipe(insert.prepend(prependContent)) .pipe(postcss(plugins)) .pipe(rename(distBasename))
163
0
79
+ 14 other calls in file
23 24 25 26 27 28 29 30 31 32
The above will compile `src/entry.js` into assets with webpack into `dist/` with the output filename of `[hash].js` (webpack generated hash of the build). You can pass webpack options in with the first argument, including `watch` which will greatly decrease compilation times: ```js return gulp.src('src/entry.js') .pipe(webpack({ watch: true, module: { rules: [
128
0
29
+ 43 other calls in file
20 21 22 23 24 25 26 27 28 29
* get wxss stream */ function wxss(wxssFileList) { if (!wxssFileList.length) return false 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('./')))
67
602
15
+ 7 other calls in file
305 306 307 308 309 310 311 312 313 314
```javascript gulp.task('speak', function() { var message = 'Tea...Earl Grey...Hot'; gulp.src('').pipe(shell('say ' + message)); }); ``` If you wish to call this task from Elixir, use the `mix.task` method and pass the name of the task as the only argument to the method:
0
290
40
+ 11 other calls in file
120 121 122 123 124 125 126 127 128
.pipe(concat('vendor.js')) .pipe(gulp.dest('_build/assets/js')); }); gulp.task('javascript:docs', function() { return gulp.src(CONFIG.JS_DOCS) .pipe(concat('docs.js')) .pipe(gulp.dest('_build/assets/js')); });
0
1
3
+ 9 other calls in file
158 159 160 161 162 163 164 165 166
const src = gulp.src(out + '/**', { base: '.' }) .pipe(rename(function (path) { path.dirname = path.dirname.replace(new RegExp('^' + out), 'out'); })) .pipe(util.setExecutableBit(['**/*.sh'])); const extensions = gulp.src('.build/extensions/**', { base: '.build', dot: true }); const sources = es.merge(src, extensions) .pipe(filter(['**', '!**/*.js.map'], { dot: true }));
0
2
0
+ 15 other calls in file
GitHub: callmecavs/bricks.js
95 96 97 98 99 100 101 102 103 104
}) // images gulp.task('images', () => { return gulp.src('src/images/**/*.{gif,jpg,png,svg}') .pipe(plumber({ errorHandler: onError })) .pipe(changed('dist/images')) .pipe(imagemin({ progressive: true, interlaced: true })) .pipe(gulp.dest('dist/images'))
209
0
73
+ 7 other calls in file