Moved the whole proj to gulp instead of grunt

This commit is contained in:
Djamil Legato
2015-04-10 11:50:28 -07:00
parent 9d4a337dd0
commit 937ffa025e
11 changed files with 492 additions and 159 deletions
+1
View File
@@ -36,3 +36,4 @@ platforms/wordpress/gantryadmin/cache
platforms/common/node_modules
assets/application/node_modules
assets/common/application/node_modules
assets/common/node_modules
-29
View File
@@ -1,29 +0,0 @@
module.exports = function(grunt) {
grunt.initConfig({
wrapup: {
build: {
requires: {
'G5': './main.js'
},
options: {
output: '../js/main.js',
sourcemap: '../js/main.js.map',
sourcemapRoot: '../application/',
sourcemapURL: 'main.js.map',
compress: false
}
}
},
watch: {
js: {
files: ['**/*.js', 'Gruntfile.js'],
tasks: ['wrapup']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-wrapup');
grunt.registerTask('default', ['watch']);
grunt.registerTask('all', ['wrapup']);
};
-15
View File
@@ -1,15 +0,0 @@
{
"name": "gantry-theme",
"version": "0.1.0",
"dependencies": {
"domready": "^1.0.7",
"elements": "git+https://git@github.com/w00fz/elements.git",
"prime": "^0.4.2"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-sass": "~0.9.2",
"grunt-contrib-watch": "~0.6.1",
"grunt-wrapup": "~0.1.3"
}
}
+143
View File
@@ -0,0 +1,143 @@
'use strict';
var gulp = require('gulp'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
merge = require('merge-stream'),
sourcemaps = require('gulp-sourcemaps'),
browserify = require('browserify'),
watchify = require('watchify'),
sass = require('gulp-ruby-sass'),
prod = !!(argv.p || argv.prod || argv.production),
watch = false;
var paths = {
js: [
{ // admin
in: './application/main.js',
out: './js/main.js'
}
],
css: []
};
var compileCSS = function(app) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_load = app.load || false,
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = '../' + app.in.substring(0, app.in.lastIndexOf('/')).split(/[\\/]/).pop();
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
var options = {
container: _out,
sourcemap: !prod,
loadPath: _load,
style: prod ? 'compressed' : 'expanded',
lineNumbers: !prod,
trace: !prod
};
return sass(_in, options)
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
.pipe(gulp.dest(_dest));
};
var compileJS = function(app, watching) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = './';
if (!watching) {
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
}
var bundle = browserify({
entries: [_in],
debug: !prod,
cache: {},
packageCache: {},
fullPaths: true
});
if (watching) {
bundle = watchify(bundle);
bundle.on('update', function(files) {
gutil.log(gutil.colors.red('>'), 'Change detected in', files.join(', '), '...');
bundleShare(bundle, _in, _out, _maps, _dest);
});
}
return bundleShare(bundle, _in, _out, _maps, _dest);
};
var bundleShare = function(bundle, _in, _out, _maps, _dest) {
return bundle.bundle()
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.pipe(source(_out))
.pipe(buffer())
// sourcemaps start
.pipe(gulpif(!prod, sourcemaps.init({ loadMaps: true })))
.pipe(gulpif(prod, uglify()))
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
// sourcemaps end
.pipe(gulp.dest(_dest));
};
gulp.task('watchify', function() {
watch = true;
// watch js
paths.js.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
return compileJS(app, true);
});
});
gulp.task('js', function() {
var streams = [];
paths.js.forEach(function(app) {
streams.push(compileJS(app));
});
return merge(streams);
});
gulp.task('css', function(done) {
var streams = [];
paths.css.forEach(function(app) {
streams.push(compileCSS(app, done));
});
return merge(streams);
});
gulp.task('watch', ['watchify'], function() {
// watch css
paths.css.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
gulp.watch(_path + '/**/*.scss', function(event) {
gutil.log(gutil.colors.red('>'), 'File', event.path, 'was', event.type);
return compileCSS(app);
});
});
});
gulp.task('all', ['css', 'js']);
gulp.task('default', ['all']);
+23
View File
@@ -0,0 +1,23 @@
{
"name": "gantry5-hydrogen",
"version": "1.0.0",
"dependencies": {
"domready": "^1.0.7",
"elements": "git+https://git@github.com/w00fz/elements.git",
"prime": "^0.4.2"
},
"devDependencies": {
"browserify": "^9.0.8",
"gulp": "^3.8.11",
"gulp-if": "^1.2.5",
"gulp-ruby-sass": "^1.0.1",
"gulp-sourcemaps": "^1.5.1",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"merge-stream": "^0.1.7",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.0",
"yargs": "^3.7.0"
}
}
+141
View File
@@ -0,0 +1,141 @@
'use strict';
var gulp = require('gulp'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
merge = require('merge-stream'),
sourcemaps = require('gulp-sourcemaps'),
browserify = require('browserify'),
watchify = require('watchify'),
sass = require('gulp-ruby-sass'),
prod = !!(argv.p || argv.prod || argv.production),
watch = false;
var paths = {
js: [],
css: [{ // nucleus
in: './scss/nucleus.scss',
out: './css-compiled/nucleus.css'
}]
};
var compileCSS = function(app) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_load = app.load || false,
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = '../' + app.in.substring(0, app.in.lastIndexOf('/')).split(/[\\/]/).pop();
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
var options = {
container: _out,
sourcemap: !prod,
loadPath: _load,
style: prod ? 'compressed' : 'expanded',
lineNumbers: !prod,
trace: !prod
};
return sass(_in, options)
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
.pipe(gulp.dest(_dest));
};
var compileJS = function(app, watching) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = './';
if (!watching) {
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
}
var bundle = browserify({
entries: [_in],
debug: !prod,
cache: {},
packageCache: {},
fullPaths: true
});
if (watching) {
bundle = watchify(bundle);
bundle.on('update', function(files) {
gutil.log(gutil.colors.red('>'), 'Change detected in', files.join(', '), '...');
bundleShare(bundle, _in, _out, _maps, _dest);
});
}
return bundleShare(bundle, _in, _out, _maps, _dest);
};
var bundleShare = function(bundle, _in, _out, _maps, _dest) {
return bundle.bundle()
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.pipe(source(_out))
.pipe(buffer())
// sourcemaps start
.pipe(gulpif(!prod, sourcemaps.init({ loadMaps: true })))
.pipe(gulpif(prod, uglify()))
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
// sourcemaps end
.pipe(gulp.dest(_dest));
};
gulp.task('watchify', function() {
watch = true;
// watch js
paths.js.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
return compileJS(app, true);
});
});
gulp.task('js', function() {
var streams = [];
paths.js.forEach(function(app) {
streams.push(compileJS(app));
});
return merge(streams);
});
gulp.task('css', function(done) {
var streams = [];
paths.css.forEach(function(app) {
streams.push(compileCSS(app, done));
});
return merge(streams);
});
gulp.task('watch', ['watchify'], function() {
// watch css
paths.css.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
gulp.watch(_path + '/**/*.scss', function(event) {
gutil.log(gutil.colors.red('>'), 'File', event.path, 'was', event.type);
return compileCSS(app);
});
});
});
gulp.task('all', ['css', 'js']);
gulp.task('default', ['all']);
+19
View File
@@ -0,0 +1,19 @@
{
"name": "gantry5-nucleus",
"version": "1.0.0",
"dependencies": {},
"devDependencies": {
"browserify": "^9.0.8",
"gulp": "^3.8.11",
"gulp-if": "^1.2.5",
"gulp-ruby-sass": "^1.0.1",
"gulp-sourcemaps": "^1.5.1",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"merge-stream": "^0.1.7",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.0",
"yargs": "^3.7.0"
}
}
+2 -2
View File
@@ -93,7 +93,7 @@ var compileJS = function(app, watching) {
if (watching) {
bundle = watchify(bundle);
bundle.on('update', function(files){
bundle.on('update', function(files) {
gutil.log(gutil.colors.red('>'), 'Change detected in', files.join(', '), '...');
bundleShare(bundle, _in, _out, _maps, _dest);
});
@@ -118,7 +118,7 @@ var bundleShare = function(bundle, _in, _out, _maps, _dest) {
.pipe(gulp.dest(_dest));
};
gulp.task('watchify', function(){
gulp.task('watchify', function() {
watch = true;
// watch js
-101
View File
@@ -1,101 +0,0 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
trace: true,
style: 'expanded',
lineNumbers: false,
loadPath: '../../engines/common/nucleus/scss/'
},
files: [{
expand: true,
cwd: 'scss',
src: ['*.scss'],
dest: 'css-compiled',
ext: '.css'
}]
}
},
browserify: {
options: {
debug: true
},
dev: {
options: {
watch: true,
browserifyOptions: {
debug: true
},
postBundleCB: function(err, src, cb) {
var through = require('through');
var stream = through().pause().queue(src).end();
var buffer = '';
stream
.pipe(require('mold-source-map').transformSourcesRelativeTo(__dirname + '/application'))
.pipe(require('exorcist')('js/main.js.map', 'main.js.map', '/G5'))
.pipe(through(function(chunk) { buffer += chunk.toString(); }, function() { cb(err, buffer); }));
stream.resume();
}
},
src: ['application/main.js'], // src: '<%= browserify.dev.src %>',
dest: 'js/main.js'
},
prod: {
options: {
postBundleCB: function(err, src, cb){
cb(err, src);
grunt.task.run('uglify');
}
},
src: ['application/main.js'], // src: '<%= browserify.dev.src %>',
dest: 'js/main.js'
}
},
exorcise: {
bundle: {
options: {
root: '/G5'
},
files: {
'js/main.js.map': ['js/main.js']
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
},
target: {
files: {
'js/main.js': ['js/main.js']
}
}
},
watch: {
css: {
files: 'scss/**/*.scss',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-exorcise');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['browserify:dev', 'exorcise', 'watch']);
grunt.registerTask('js', ['browserify:prod']);
grunt.registerTask('css', ['sass']);
grunt.registerTask('all', ['sass', 'browserify']);
};
+149
View File
@@ -0,0 +1,149 @@
'use strict';
var gulp = require('gulp'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
merge = require('merge-stream'),
sourcemaps = require('gulp-sourcemaps'),
browserify = require('browserify'),
watchify = require('watchify'),
sass = require('gulp-ruby-sass'),
prod = !!(argv.p || argv.prod || argv.production),
watch = false;
var paths = {
js: [
{ // admin
in: './application/main.js',
out: './js/main.js'
}
],
css: [
{ // admin
in: './scss/admin.scss',
out: './css-compiled/admin.css',
load: '../../engines/common/nucleus/scss'
}
]
};
var compileCSS = function(app) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_load = app.load || false,
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = '../' + app.in.substring(0, app.in.lastIndexOf('/')).split(/[\\/]/).pop();
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
var options = {
container: _out,
sourcemap: !prod,
loadPath: _load,
style: prod ? 'compressed' : 'expanded',
lineNumbers: !prod,
trace: !prod
};
return sass(_in, options)
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
.pipe(gulp.dest(_dest));
};
var compileJS = function(app, watching) {
var _in = app.in,
_out = app.out.split(/[\\/]/).pop(),
_dest = app.out.substring(0, app.out.lastIndexOf('/')),
_maps = './' + app.in.substring(0, app.in.lastIndexOf('/')).split(/[\\/]/).pop();
if (!watching) {
gutil.log(gutil.colors.blue('*'), 'Compiling', _in);
}
var bundle = browserify({
entries: [_in],
debug: !prod,
cache: {},
packageCache: {},
fullPaths: true
});
if (watching) {
bundle = watchify(bundle);
bundle.on('update', function(files) {
gutil.log(gutil.colors.red('>'), 'Change detected in', files.join(', '), '...');
bundleShare(bundle, _in, _out, _maps, _dest);
});
}
return bundleShare(bundle, _in, _out, _maps, _dest);
};
var bundleShare = function(bundle, _in, _out, _maps, _dest) {
return bundle.bundle()
.on('end', function() {
gutil.log(gutil.colors.green('√'), 'Saved ' + _in);
})
.pipe(source(_out))
.pipe(buffer())
// sourcemaps start
.pipe(gulpif(!prod, sourcemaps.init({ loadMaps: true })))
.pipe(gulpif(prod, uglify()))
.on('error', gutil.log)
.pipe(gulpif(!prod, sourcemaps.write('.', { sourceRoot: _maps })))
// sourcemaps end
.pipe(gulp.dest(_dest));
};
gulp.task('watchify', function() {
watch = true;
// watch js
paths.js.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
return compileJS(app, true);
});
});
gulp.task('js', function() {
var streams = [];
paths.js.forEach(function(app) {
streams.push(compileJS(app));
});
return merge(streams);
});
gulp.task('css', function(done) {
var streams = [];
paths.css.forEach(function(app) {
streams.push(compileCSS(app, done));
});
return merge(streams);
});
gulp.task('watch', ['watchify'], function() {
// watch css
paths.css.forEach(function(app) {
var _path = app.in.substring(0, app.in.lastIndexOf('/'));
gulp.watch(_path + '/**/*.scss', function(event) {
gutil.log(gutil.colors.red('>'), 'File', event.path, 'was', event.type);
return compileCSS(app);
});
});
});
gulp.task('all', ['css', 'js']);
gulp.task('default', ['all']);
+14 -12
View File
@@ -1,6 +1,6 @@
{
"name": "gantry-admin",
"version": "0.1.0",
"name": "gantry5-admin",
"version": "1.0.0",
"dependencies": {
"agent": "^0.2.1",
"async": "^0.9.0",
@@ -16,15 +16,17 @@
"sortablejs": "^1.1.1"
},
"devDependencies": {
"browserify": "^9.0.7",
"exorcist": "^0.1.6",
"grunt": "~0.4.5",
"grunt-browserify": "^3.6.0",
"grunt-contrib-sass": "~0.9.2",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "~0.6.1",
"grunt-exorcise": "^1.0.1",
"mold-source-map": "^0.3.0",
"through": "^2.3.7"
"browserify": "^9.0.8",
"gulp": "^3.8.11",
"gulp-if": "^1.2.5",
"gulp-ruby-sass": "^1.0.1",
"gulp-sourcemaps": "^1.5.1",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"merge-stream": "^0.1.7",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.0",
"yargs": "^3.7.0"
}
}