Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Log browserify errors
.on("error", util.log.bind(util, "Browserify Error"))
// Bundle the application
.bundle()
// Rename the bundled file to relativeFilename
.pipe(source(relativeFilename))
// Convert stream to a buffer
.pipe(buffer())
// Save the source map for later (uglify will remove it since it is a comment)
.pipe(sourcemaps.init({loadMaps: true}))
// Save normal source (useful for debugging)
.pipe(gulp.dest(APPS_DIST_DIR))
// Minify source for production
.pipe(uglify())
// Restore the sourceMap
.pipe(sourcemaps.write())
// Add the .min suffix before the extension
.pipe(rename({suffix: ".min"}))
// Log the bundle size
.pipe(size(SIZE_OPTS))
// Write the minified file.
.pipe(gulp.dest(APPS_DIST_DIR));
}
qmLog.info("Not renaming minified files because we can't remove from old ones from cordova hcp server");
}
return gulp.src("src/" + sourceIndexFileName)
//.pipe(useref()) // Concatenate with gulp-useref
.pipe(useref({}, lazypipe().pipe(sourcemaps.init, { loadMaps: true })))
.pipe(jsFilter)
.pipe(uglify({mangle: false})) // Minify any javascript sources (Can't mangle Angular files for some reason)
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
.pipe(indexHtmlFilter)
.pipe(ifElse(renameForCacheBusting, rev)) // Rename the concatenated files for cache busting (but not index.html)
.pipe(indexHtmlFilter.restore)
.pipe(ifElse(renameForCacheBusting, revReplace)) // Substitute in new filenames for cache busting
.pipe(sourcemaps.write('.', sourceMapsWriteOptions))
//.pipe(rev.manifest('rev-manifest.json'))
// .pipe(through.obj(function (file, enc, cb) {
// console.log(file.revOrigPath); //=> /Users/.../project_manage.js
// console.log(file.revHash); //=> '4ad9f04399'
//
// // write the NEW path
// file.path = modify(file.revOrigPath, function (name, ext) {
// return name + '_' + file.revHash + '.min' + ext;
// }); //=> 'project_manage_4ad9f04399.min.js
// console.log(file.path);
// // send it back to stream
// cb(null, file);
// }))
.pipe(gulp.dest('www'))
;
}
gulp.task('css', function(){
// app css
return gulp.src(cssFiles)
.pipe(sourcemaps.init({debug:true}))
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
// .pipe(plugins.concat('style.min.css'))
.pipe(plugins.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4', 'Firefox >= 4'))
.pipe(isProduction ? plugins.cssmin() : gutil.noop())
.pipe(plugins.size())
.on('error', function(err){
new gutil.PluginError('CSS', err, {showStack: true});
})
.pipe(plugins.notify())
.pipe(gulp.dest(cssDest));
});
gulp.task('less', function() {
return gulp.src('./frontend/less/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./static'));
});
'src/css/animate.css',
'src/css/magnific-popup.css',
'src/css/fonts.css',
'src/css/responsive.css',
'src/css/btcrelay.css'
])
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(concat('all.css'))
.pipe(gulp.dest('tmp'))
.pipe(rename('all.min.css'))
.pipe(sourcemaps.init())
.pipe(minifyCSS())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/css'))
.pipe(notify({ message: 'CSS minification complete' }));
});
sFiles.map((file, key) => {
let files = sMap[file].map(item => `${SRC.dir}/scripts/${item}`)
gulp.src(files, SRC_OPTION)
.pipe(sourcemaps.init())
.pipe(concat(`scripts/${file}.js`))
.pipe(pathTask())
.pipe(babel({
presets: ['env']
}))
.pipe(gulpif(isPROD, uglify()))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(DIST.asset))
.pipe(connect.reload())
.on('end', () => {
count++
if (count === sFiles.length) {
done()
log('🚀 . build script done ... ')
}
})
})
})
function scripts() {
return gulp
.src(paths.scripts.src)
.pipe(sourcemaps.init())
.pipe(terser())
.pipe(concat("main.min.js"))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.scripts.dest));
}
const minifier = isES => () => gulp.src(`dist/lamb${isES ? ".esm" : ""}.js`)
.pipe(sourcemaps.init())
.pipe(terser({ mangle: { module: isES }, output: { comments: "some" } }))
.pipe(rename({ extname: ".min.js" }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("dist"));
});
lessc.on('error',function(e){
gutil.log(e);
lessc.end();
});
if (production) {
return gulp.src('./public/less/components.less')
.pipe(lessc)
.pipe(gulp.dest('./public/css'));
} else {
return gulp.src('./public/less/components.less')
.pipe(sourcemaps.init())
.pipe(lessc)
.pipe(sourcemaps.write())
.pipe(gulp.dest('./public/css'));
}
});
gulp.task('build-ts',()=>{
return gulp.src(PATHS.scripts)
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(babel({
presets: ['env']
}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(PATHS.output));
});