diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04c01ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..179e77d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,76 @@ +var path = require('path'); +var browserify = require('browserify'); +var watchify = require('watchify'); +var source = require('vinyl-source-stream'); +var gulp = require('gulp'); +var newer = require('gulp-newer'); +var clean = require('gulp-clean'); +var less = require('gulp-less'); + +var package = require('./package.json'); + +var folders = { + src: 'src/', + dist: 'dist/' +}; + +var browserifyOpts = { + entries: [package.main], + transform: [], + extensions: ['.js', '.json'], + cache: {}, + packageCache: {} +}; + +function blob(fpath, extension) { + return path.join(fpath, '**', '*.' + extension); +} + +// Tasks +gulp.task('default', ['build']); + +gulp.task('build', ['application', 'style', 'static']); + +gulp.task('clean', function () { + gulp.src(folders.dist) + .pipe(clean()); +}); + +// By domain +gulp.task('application', ['js']); + +gulp.task('style', ['less']); + +gulp.task('static', ['html', 'svg']); + +// By file +gulp.task('html', function () { + gulp.src(blob(folders.src, 'html')) + .pipe(newer(folders.dist)) + .pipe(gulp.dest(folders.dist)); +}); + +gulp.task('js', function () { + var brow = browserify(browserifyOpts) + + brow.bundle() + .pipe(source('index.js')) + .pipe(gulp.dest(folders.dist)); +}); + +gulp.task('less', function () { + var srcs = [ + blob(folders.src, 'css'), + blob(folders.src, 'less') + ]; + + gulp.src(srcs) + .pipe(less()) + .pipe(gulp.dest(folders.dist)); +}); + +gulp.task('svg', function () { + gulp.src(blob(folders.src, 'svg')) + .pipe(newer(folders.dist)) + .pipe(gulp.dest(folders.dist)); +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..b946c46 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "unit-website", + "version": "0.0.1", + "description": "Unit fron page", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@git.unit.macaomilano.org:subnixr/website.git" + }, + "author": "Unit", + "license": "GPL-3.0", + "devDependencies": { + "browserify": "^14.4.0", + "gulp": "^3.9.1", + "gulp-clean": "^0.3.2", + "gulp-less": "^3.3.0", + "gulp-newer": "^1.3.0", + "vinyl-source-stream": "^1.1.0", + "vinyl-transform": "^1.0.0", + "watchify": "^3.9.0" + } +}