-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
127 lines (104 loc) · 3.5 KB
/
Copy pathgulpfile.js
File metadata and controls
127 lines (104 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
'use strict';
var exec = require('child_process').exec, child;
var colors = require('colors');
var gulp = require('gulp');
var webpack = require('webpack-stream');
// browserify = require('browserify'),
// uglify = require('gulp-uglify'),
// source = require('vinyl-source-stream'),
// buffer = require('vinyl-buffer'),
// sourcemaps = require('gulp-sourcemaps'),
// gutil = require('gulp-util'),
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
// webpack = require('webpack'),
// WebpackDevServer = require('webpack-dev-server'),
var autoprefixer = require('gulp-autoprefixer');
// livereload = require('gulp-livereload');
gulp.task('scripts', function () {
// Future processing for scripts
gulp.watch("src/*.js", [
"webpack"
]);
});
gulp.task('styles', function () {
gulp.src('scss/*.scss')
.pipe(sass({
includePaths: ['./scss', './node_modules/support-for/sass/']
}).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(cssnano())
.pipe(gulp.dest('css'));
// .pipe(livereload());
});
gulp.task('sass:watch', function () {
// livereload.listen();
gulp.watch('scss/*.scss', ['styles']);
});
// gulp.task("webpack", function(callback) {
// // run webpack
// webpack(require("./webpack.config.js"), function(err, stats) {
// if(err) throw new gutil.PluginError("webpack", err);
// gutil.log("[webpack]", stats.toString({
// // output options
// }));
// callback();
// });
// });
gulp.task("webpack-dev-server", function(callback) {
// Start a webpack-dev-server
var compiler = webpack(require("./webpack.config.js"));
new WebpackDevServer(compiler, {
// server and middleware options
}).listen(8080, "localhost", function(err) {
if(err) throw new gutil.PluginError("webpack-dev-server", err);
// Server listening
gutil.log("[webpack-dev-server]", "http://localhost:8080/webpack-dev-server/index.html");
// keep the server alive or continue?
// callback();
});
});
gulp.task("webpack", function(callback) {
return gulp.src("src/index.js")
.pipe(webpack(require("./webpack.config.js")))
.pipe(gulp.dest("public/"));
});
gulp.task('zip_project', function() {
child = exec("zip -r ./upnext.zip * -x '*.DS_Store' 'node_modules/*'", function(error, stdout, stderr) {
// console.log(stdout.split("\n"));
console.log(stdout);
});
// console.log(typeof child);
// child();
});
gulp.task('clone_project', function() {
shell("rsync -av --exclude='node_modules' --exclude='.git' --exclude='*.DS_Store' . ~/Desktop/Daniel/newProj_" + Date.now());
});
function shell(cmd) {
console.log(colors.yellow.bold("Running " + cmd));
exec(cmd, function(error, stdout, stderr){
if(error !== null) {
throw colors.red(error);
}
console.log(stdout);
console.log(colors.green("Script successful"));
});
}
// gulp.task('javascript', function () {
// // set up the browserify instance on a task basis
// var b = browserify({
// entries: './entry.js',
// debug: true
// });
//
// return b.bundle()
// .pipe(source('app.js'))
// .pipe(buffer())
// .pipe(sourcemaps.init({loadMaps: true}))
// // Add transformation tasks to the pipeline here.
// .pipe(uglify())
// .on('error', gutil.log)
// .pipe(sourcemaps.write('./'))
// .pipe(gulp.dest('./dist/js/'));
// });
gulp.task('default', ['styles', 'sass:watch', 'webpack-dev-server']);