diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..e051dca23 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,115 @@ +var gulp = require('gulp'); +var less = require('gulp-less'); +var sourcemaps = require('gulp-sourcemaps'); +var clean = require('gulp-clean'); +var include = require('gulp-include'); +var uglify = require('gulp-uglify'); + +var cssDestination = './public/temp/css'; +var jsDestination = './public/temp/js'; + +gulp.task('default', [ + 'build' +]); + +gulp.task('build', [ + 'less-vendor', + 'less-highlight', + 'less-custom', + 'scripts-vendor', + 'scripts-highlight', + 'scripts-custom' +]); + +gulp.task('less-vendor', function () { + return gulp + .src('./public/assets/less/vendor.less') + .pipe(sourcemaps.init()) + .pipe(less({ + paths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(cssDestination)); +}); + +gulp.task('less-highlight', function () { + return gulp + .src('./public/assets/less/highlight.less') + .pipe(sourcemaps.init()) + .pipe(less({ + paths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(cssDestination)); +}); + +gulp.task('less-custom', function () { + return gulp + .src('./public/assets/less/index.less') + .pipe(sourcemaps.init()) + .pipe(less({ + paths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(cssDestination)); +}); + +gulp.task('scripts-vendor', function () { + return gulp + .src('./public/assets/scripts/vendor.js') + .pipe(sourcemaps.init()) + .pipe(include({ + includePaths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(uglify()) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(jsDestination)); +}); + +gulp.task('scripts-highlight', function () { + return gulp + .src('./public/assets/scripts/highlight.js') + .pipe(sourcemaps.init()) + .pipe(include({ + includePaths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(uglify()) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(jsDestination)); +}); + +gulp.task('scripts-custom', function () { + return gulp + .src('./public/assets/scripts/index.js') + .pipe(sourcemaps.init()) + .pipe(include({ + includePaths: [ + __dirname + '/node_modules' + ] + })).on('error', console.log) + .pipe(uglify()) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(jsDestination)); +}); + +gulp.task('clean', function () { + return gulp + .src([cssDestination, jsDestination]) + .pipe(clean()); +}); + +gulp.task('watch', function () { + return gulp + .watch('./public/assets/less/*.less', ['less-custom']) + .watch('./public/assets/scripts/*.js', ['scripts-custom']); +}); diff --git a/package.json b/package.json index 0958a05e2..b8fd9d558 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,20 @@ "email": "security@gitea.io" }, "config": {}, - "scripts": {}, + "scripts": { + "build": "gulp build", + "clean": "gulp clean", + "watch": "gulp watch" + }, "main": "", - "devDependencies": {}, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-clean": "^0.3.2", + "gulp-include": "^2.3.1", + "gulp-less": "^3.3.0", + "gulp-sourcemaps": "^1.9.1", + "gulp-uglify": "^2.0.0" + }, "dependencies": { "@claviska/jquery-minicolors": "^2.2.4", "@ryancavanaugh/jquery.are-you-sure": "0.0.14-alpha",