html -> pug; every folder in scripts -> /folder.min.js
This commit is contained in:
parent
2e22418e07
commit
29f924bf4c
11 changed files with 53 additions and 31 deletions
9
client/pug/game.pug
Normal file
9
client/pug/game.pug
Normal file
|
@ -0,0 +1,9 @@
|
|||
doctype html
|
||||
html
|
||||
head
|
||||
title Crafty Things
|
||||
link(rel='stylesheet', href='style.css')
|
||||
script(src='/socket.io/socket.io.js')
|
||||
script(src='lib.min.js')
|
||||
script(src='game.min.js')
|
||||
body
|
61
gulpfile.js
61
gulpfile.js
|
@ -1,31 +1,22 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var merge = require('merge-stream');
|
||||
var gulp = require('gulp');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var coffee = require('gulp-coffee');
|
||||
var pug = require('gulp-pug');
|
||||
var insert = require('gulp-insert');
|
||||
var uglify = require('gulp-uglify-es').default;
|
||||
var concat = require('gulp-concat');
|
||||
|
||||
var paths = {
|
||||
coffee: 'client/scripts/**/*.coffee',
|
||||
lib: 'client/lib/**/*.js',
|
||||
images: 'client/img/**/*',
|
||||
dest: 'static',
|
||||
maps: 'maps'
|
||||
lib: 'client/lib/*.js',
|
||||
coffee: 'client/scripts',
|
||||
pug: 'client/pug/*.pug',
|
||||
dest: 'static',
|
||||
maps: 'maps'
|
||||
};
|
||||
|
||||
gulp.task('coffee', function(){
|
||||
return gulp.src(paths.coffee)
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat('app.min.js'))
|
||||
.pipe(coffee({bare: true}))
|
||||
.pipe(insert.transform(function(contents, file) {
|
||||
return '$(function () {' + contents + '});';
|
||||
}))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write(paths.maps))
|
||||
.pipe(gulp.dest(paths.dest))
|
||||
});
|
||||
|
||||
gulp.task('lib', function(){
|
||||
return gulp.src(paths.lib)
|
||||
.pipe(sourcemaps.init())
|
||||
|
@ -34,4 +25,36 @@ gulp.task('lib', function(){
|
|||
.pipe(gulp.dest(paths.dest))
|
||||
});
|
||||
|
||||
gulp.task('default', [ 'coffee', 'lib' ]);
|
||||
function getFolders(dir) {
|
||||
return fs.readdirSync(dir)
|
||||
.filter(function(file) {
|
||||
return fs.statSync(path.join(dir, file)).isDirectory();
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('coffee', function(){
|
||||
var folders = getFolders(paths.coffee);
|
||||
|
||||
var tasks = folders.map(function(folder) {
|
||||
return gulp.src(path.join(paths.coffee, folder, '/**/*.coffee'))
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat(folder + '.min.js'))
|
||||
.pipe(coffee({bare: true}))
|
||||
.pipe(insert.transform(function(contents, file) {
|
||||
return '$(function () {' + contents + '});';
|
||||
}))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write(paths.maps))
|
||||
.pipe(gulp.dest(paths.dest))
|
||||
});
|
||||
|
||||
return merge(tasks);
|
||||
});
|
||||
|
||||
gulp.task('pug', function(){
|
||||
return gulp.src(paths.pug)
|
||||
.pipe(pug())
|
||||
.pipe(gulp.dest(paths.dest))
|
||||
});
|
||||
|
||||
gulp.task('default', [ 'lib', 'coffee', 'pug' ]);
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
"express": "^4.16.1",
|
||||
"helmet": "*",
|
||||
"socket.io": "^2.1.1",
|
||||
"merge-stream": "*",
|
||||
"gulp": "*",
|
||||
"gulp-sourcemaps": "*",
|
||||
"gulp-pug": "*",
|
||||
"gulp-coffee": "*",
|
||||
"gulp-insert": "*",
|
||||
"gulp-uglify-es": "*",
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Crafty Things</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="lib.min.js"></script>
|
||||
<script src="app.min.js"></script>
|
||||
</head>
|
||||
<body />
|
||||
</html>
|
Reference in a new issue