-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (72 loc) · 2.53 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
77
78
79
80
81
const gulp = require('gulp')
const log = require('fancy-log')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
const browserify = require('browserify')
const babelify = require('babelify')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const ngAnnotate = require('gulp-ng-annotate')
const uglify = require('gulp-uglify')
const stringify = require('stringify')
const rename = require('gulp-rename')
const zip = require('gulp-zip')
const concatCss = require('gulp-concat-css');
const sourcemaps = require('gulp-sourcemaps');
const project = 'district-wide-surveys';
const userHome = require("user-home");
const extensionpath = userHome + "\\Documents\\Qlik\\Sense\\Extensions";
const base = '';
log(userHome);
gulp.task('qext', function(){
gulp.src('./src/project.qext')
.pipe(rename(`${project}.qext`))
.pipe(gulp.dest(`./${project}`))
.pipe(gulp.dest(extensionpath + `/${project}`))
})
gulp.task('html', function(){
gulp.src(['./src/index.html', './src/app/*.html'])
.pipe(gulp.dest(`./${project}`))
.pipe(gulp.dest(extensionpath + `/${project}`))
})
gulp.task('style', function(){
gulp.src(['./src/app/**/*.scss', './src/app/*.scss', './src/*.css'])
.pipe(sass())
.pipe(sass({ outputStyle: 'compressed'}))
.pipe(autoprefixer())
.pipe(concatCss('styles.css', {rebaseUrls:false}))
.pipe(gulp.dest(`./${project}/css`))
.pipe(gulp.dest(extensionpath + `/${project}/css`))
})
gulp.task('js', function(){
browserify({
entries: './src/app/main.js',
debug: true
})
.transform('babelify', { presets: ['es2015'] })
.transform(stringify, { appliesTo: { includeExtensions: ['.html'] } })
.bundle()
.pipe(source('config.js'))
.pipe(buffer())
.pipe(ngAnnotate())
// .pipe(uglify())
.pipe(gulp.dest(`./${project}/app`))
.pipe(gulp.dest(extensionpath + `/${project}/app`))
})
gulp.task('assets', function(){
gulp.src('./src/img/**')
.pipe(gulp.dest(`./${project}/img`))
.pipe(gulp.dest(extensionpath + `/${project}/img`))
})
gulp.task('zip', ['qext','html','style','js','assets'], () =>
gulp.src(`./${project}/**`)
.pipe(zip(`${project}.zip`))
.pipe(gulp.dest('./'))
);
gulp.task('watch', function(){
gulp.watch('./src/app/**/*.js', ['js'])
gulp.watch(['./src/app/**/*.scss', './src/app/*.scss', './src/*.css'], ['style'])
gulp.watch(['./src/index.html'], ['html'])
gulp.watch('./src/app/**/*.html', ['js'])
})
gulp.task('default', ['qext', 'html', 'style', 'js', 'assets'])