Skip to content

Commit 2197c7a

Browse files
committed
Add build tools + update to v1.2.16
1 parent e0616d3 commit 2197c7a

25 files changed

+11486
-2659
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
node_modules/
3+
build/*
4+
build
5+
local
6+
local/*
7+
.idea/workspace.xml

README.md

Lines changed: 0 additions & 94 deletions
This file was deleted.

gulp/handleErrors.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var notify = require("gulp-notify");
2+
3+
module.exports = function() {
4+
5+
var args = Array.prototype.slice.call(arguments);
6+
7+
// Send error to notification center with gulp-notify
8+
notify.onError({
9+
title: "Compile Error",
10+
message: "<%= error %>"
11+
}).apply(this, args);
12+
13+
// Keep gulp from hanging on this task
14+
this.emit('end');
15+
};

gulpfile.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Search & Filter
2+
3+
/* ==========
4+
* REQUIRE
5+
* ========== */
6+
var gulp = require('gulp');
7+
var plugins = require('gulp-load-plugins')(); //auto load `gulp
8+
var rename = require('gulp-rename'); //change filename before saving
9+
var del = require('del'); //for cleaning up the folder on rebuild
10+
var fs = require('fs'); //for cleaning up the folder on rebuild
11+
var path = require('path');
12+
13+
var handleErrors = require('./gulp/handleErrors');
14+
15+
16+
/* ==========
17+
* CONFIG
18+
* ========== */
19+
var projectDefaults = {
20+
name: 'search-filter-free',
21+
build: './build',
22+
publicApp: {},
23+
src: 'src/',
24+
dev: 'dist/',
25+
dist: 'dist/'
26+
};
27+
let project = projectDefaults;
28+
29+
const localBuildConfigPath = './local/config.js';
30+
if ( fs.existsSync( localBuildConfigPath ) ) {
31+
// We have a local config we want to merge
32+
const localBuildConfig = require( localBuildConfigPath );
33+
project = { ...projectDefaults, ...localBuildConfig };
34+
}
35+
36+
project.publicApp = {
37+
src: './'+project.src+'/public/assets/js/',
38+
cssSrc: './'+project.src+'/public/assets/css/',
39+
40+
build: project.build+'/public/assets/js/',
41+
cssBuild: project.build+'/public/assets/css/',
42+
43+
dist: './'+project.dev+'/public/assets/js/'
44+
}
45+
46+
47+
var appTasks = new Array(); //contain references to dynamically generated app tasks - app tasks are tasks which are specific to a particular game
48+
appTasks['scripts'] = new Array();
49+
appTasks['templates'] = new Array();
50+
51+
// config for tasks & modules
52+
var options = {
53+
uglify: {
54+
compress: {
55+
drop_console: true //always remove console.logs - dist should never have console.logs
56+
},
57+
mangle: true
58+
},
59+
minifyCss: {
60+
//keepBreaks: true,
61+
compatibility: 'ie8',
62+
keepSpecialCommentsBreaks: true
63+
},
64+
}
65+
66+
/* ==========
67+
* TASKS
68+
* ========== */
69+
70+
gulp.task('copy-plugin', function ( done ) {
71+
gulp.src([
72+
project.src+'**/*',
73+
'!'+project.publicApp.src+"**/*",
74+
'!'+project.publicApp.cssSrc+"**/*"
75+
76+
]).pipe(plugins.newer(project.build)).pipe(gulp.dest(project.build));
77+
done();
78+
});
79+
80+
function ensureDirectoryExistence(filePath) {
81+
var dirname = path.dirname(filePath);
82+
if (fs.existsSync(dirname)) {
83+
return true;
84+
}
85+
ensureDirectoryExistence(dirname);
86+
fs.mkdirSync(dirname);
87+
}
88+
89+
90+
/*
91+
* Utility functions
92+
*/
93+
gulp.task('clean', function (cb) {
94+
del([
95+
project.build+'**/*.*',
96+
project.dev+'**/*.*',
97+
project.build+'**',
98+
project.dev+'**'
99+
], cb);
100+
});
101+
102+
gulp.task('watch', function( done ) {
103+
//wait for changes and run tasks accordingly
104+
gulp.watch([
105+
project.src+'**/*',
106+
], gulp.series('copy-plugin') );
107+
108+
done();
109+
});
110+
111+
112+
gulp.task('default', gulp.series( 'copy-plugin', 'watch', function( done ) {
113+
console.log("Init main tasks");
114+
done();
115+
} ) );

0 commit comments

Comments
 (0)