Last active
September 19, 2016 14:38
-
-
Save alxy/637eb45c350b13ad5413ab1df2b895eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Dependencies | |
| // | |
| var gulp = require('gulp'); | |
| var path = require('path'); | |
| var js = require('./gulp/js'); | |
| // | |
| // Tasks | |
| // | |
| var widget_scripts = function() { | |
| gulp.watch([ | |
| './widgets/**/*/js/*', | |
| './formwidgets/**/*/js/*', | |
| './components/**/*/js/*' | |
| ], function(obj) { | |
| var file = path.parse(obj.path); | |
| var directory = path.relative('.', file.dir) + './../compiled'; | |
| return js(obj.path, file.name, directory); | |
| }); | |
| }; | |
| gulp.task('widget-scripts', widget_scripts); | |
| // | |
| // Watchers | |
| // | |
| gulp.task('default', [ | |
| 'widget-scripts' | |
| //'widget-styles', | |
| // 'phpunit', | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Dependencies | |
| // | |
| var gulp = require('gulp'); | |
| var babel = require('babelify'); | |
| var stringify = require('stringify'); | |
| var browserify = require('browserify'); | |
| var uglify = require('gulp-uglify'); | |
| var gutil = require('gulp-util'); | |
| var buffer = require('vinyl-buffer'); | |
| var sourcemaps = require('gulp-sourcemaps'); | |
| var source = require('vinyl-source-stream'); | |
| // | |
| // Compile widget scripts | |
| // | |
| module.exports = function (path, filename, output_dir) { | |
| browserify(path, {debug: true, extensions: ['.js']}) | |
| .transform(stringify({ | |
| extensions: ['.htm'], | |
| minify: true, | |
| minifier: {extensions: ['.htm']}, | |
| })) | |
| .transform(babel) | |
| .bundle() | |
| .on('success', gutil.log) | |
| .pipe(source(filename + '.min.js')) | |
| .on('success', gutil.log) | |
| .pipe(buffer()) | |
| .on('success', gutil.log) | |
| .pipe(sourcemaps.init({loadMaps: true})) | |
| .on('success', gutil.log) | |
| .pipe(uglify()) | |
| .on('success', gutil.log) | |
| .pipe(sourcemaps.write('./')) | |
| .on('success', gutil.log) | |
| .pipe(gulp.dest(output_dir)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment