This repository has been archived by the owner on Apr 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
76 lines (63 loc) · 2.31 KB
/
gulpfile.js
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
var path = require('path');
var gulp = require('gulp');
var changed = require('gulp-changed');
var gulpif = require('gulp-if');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var beautify = require('gulp-beautify');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var less = require('gulp-less');
var rename = require('gulp-rename');
var config = {
release: process.env.RELEASE !== undefined,
materialize_path: 'node_modules/materialize-css/bin',
less_path: 'powerapp/project_static/less',
js_files: [
"node_modules/jquery/dist/jquery.js",
"node_modules/materialize-css/bin/materialize.js",
"powerapp/project_static/js_src/*.js"
],
less_files: [
"powerapp/project_static/less/*.less"
],
font_files: [
"node_modules/materialize-css/font/**/*"
]
};
// Take css file from materialize, rename it to less and add to "our library"
gulp.task('lessify-materialize', function() {
var target = path.join(config.less_path, "lib");
return gulp.src(path.join(config.materialize_path, "*.css"))
.pipe(changed(target, {extension: ".less"}))
.pipe(rename({extname: ".less"}))
.pipe(gulp.dest(target))
});
// Compile all less files to one big CSS
gulp.task('styles', ['lessify-materialize'], function() {
gulp.src(path.join(config.less_path, "*.less"))
.pipe(less({paths: [config.less_path]}))
.pipe(gulpif(config.release, uglifycss()))
.pipe(autoprefixer())
.pipe(concat("style.css"))
.pipe(gulp.dest("powerapp/project_static/css"));
});
gulp.task('scripts', function() {
gulp.src(config.js_files)
.pipe(gulpif(config.release, sourcemaps.init()))
.pipe(gulpif(config.release, uglify(), beautify()))
.pipe(concat("script.js"))
.pipe(gulpif(config.release, sourcemaps.write()))
.pipe(gulp.dest("powerapp/project_static/js"));
});
gulp.task('fonts', function() {
gulp.src(config.font_files)
.pipe(gulp.dest("powerapp/project_static/font"));
});
gulp.task('default', ['scripts', 'styles', 'fonts']);
gulp.task('watch', ['default'], function() {
gulp.watch([
config.js_files, config.less_files, config.font_files
], ['default']);
});