Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('scripts-typescript', 'Transpile TypeScript to ES6, include references to library and app .d.ts files and generate sourcemaps', () =>{
// references:
// https://www.npmjs.com/package/gulp-typescript
let tsProject = ts.createProject('tsconfig.json', {
typescript: require('typescript'), // override the typescript version by that defined in package.json
// configuration defined in tsconfig.json
// other overrides here if needed
// http://json.schemastore.org/tsconfig
// https://github.com/Microsoft/TypeScript/wiki/Compiler%20Options
});
let tsResult = utils.plumbedSrc(config.typescript.src) // handle errors nicely (i.e., without breaking watch)
.pipe(sourcemaps.init())
.pipe(ts(
tsProject
));
// Output files
tsResult.dts.pipe(gulp.dest(config.typescript.dest));
return tsResult.js
.pipe(sourcemaps.write('.', { // use '.' to write the sourcemap to a separate file in the same dir
// sourcemaps need to be written to separate files otherwise Babel freaks out (!)
includeContent: false, // alternative: include the contents and remove sourceRoot. Avoids issues but prevents from editing the sources directly in the browser
sourceRoot: '/' // use an absolute path because we have scripts in different subpaths
}))
// Output files
.pipe(gulp.dest(config.typescript.dest))
if (debug) {
bundler.on('error', function(err) {
gutil.log(gutil.colors.red('Browserify error:'), err)
})
}
var bundleStream = bundler
.pipe(source(config.jsBundleInput))
.pipe(ngAnnotate())
var templateStream = gulp.src(config.views)
.pipe(templateCache({module: config.moduleName}))
merge2(bundleStream, templateStream)
.pipe(buffer())
.pipe(gulpif(!debug, sourcemaps.init()))
.pipe(concat(config.jsBundleName))
.pipe(gulpif(!debug, uglify()))
.pipe(gulpif(!debug, sourcemaps.write('.')))
.pipe(gulp.dest(config.dist))
}
function autoprefix() {
return gulp.src('./src/**/*.css')
.pipe(sourcemaps.init())
.pipe(postcss([ autoprefixer({ browsers: ['last 3 versions'] }) ]))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dest'));
}
function compileTs(files, watchMode) {
watchMode = watchMode || false;
var tsProject = ts.createProject('tsconfig.json');
var allFiles = [].concat(files, typingFiles);
var res = gulp.src(allFiles, {
base: config.src,
outDir: config.tmp
})
.pipe(tslint({
formatter: 'verbose'
}))
.pipe(tslint.report())
.pipe(sourcemaps.init())
.pipe(tsProject())
.on('error', function () {
if (watchMode) {
return;
}
process.exit(1);
});
return res.js
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.tmp));
}
gulp.task('js', function () {
var b = browserify({
entries: './app/_js/main.js',
debug: true,
bundleExternal: false,
builtins: false,
commondir: false,
insertGlobals: 'global',
transform: [vueify, babelify]
})
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./app/assets/js/'))
})
gulp.task('uglified', function () {
return browserify(browserifyConfig)
.bundle()
.pipe(source('set-functions.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('js', function(){
return gulp.src('src/javascript/*.js')
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/js'))
});
gulp.task('build.js.dev', function () {
var result = gulp.src('./app/**/*ts')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return result.js
.pipe(sourcemaps.write())
.pipe(template({ VERSION: getVersion() }))
.pipe(gulp.dest(PATH.dest.dev.all));
});
function rebundle(devBundle) {
if (devBundle) {
gutil.log('Starting dev rebundle...');
}
var debug, min;
debug = sourcemaps.init({loadMaps: true});
debug.pipe(sourcemaps.write('./', {sourceRoot: './'}))
.pipe(gulp.dest(paths.out));
min = rename({ suffix: '.min' });
min.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./', {sourceRoot: './', addComment: false}))
.pipe(gulp.dest(paths.out));
var stream = this.bundle()
.on('error', handleErrors.handler)
.pipe(handleErrors())
.pipe(source('gown-full.js'))
.pipe(buffer());
if (devBundle) {