-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (53 loc) · 1.78 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
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha-phantomjs');
const header = require('gulp-header');
const webpack = require('webpack-stream');
const scsslint = require('gulp-scss-lint');
const sass = require('gulp-sass');
const pkg = require('./package.json');
const webpackConfig = require('./webpack.config');
const testWebpackConfig = require('./webpack.test.config');
const banner = '/*! <%= pkg.name %> - v<%= pkg.version %> | <%= new Date().getFullYear() %> */\n';
gulp.task('test-script-format', () =>
gulp.src(['./src/js/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError())
);
gulp.task('compile-test-script', () =>
gulp.src(['./test/index.js'])
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('./test/compiled/'))
);
// Disabled for now
gulp.task('test-mocha', ['script-compile-test'], () =>
gulp.src(['test/test.html'])
.pipe(mocha({ reporter: 'spec' }))
);
gulp.task('test-script', ['test-script-format']);
gulp.task('build-script', ['test-script'], () =>
gulp.src(['./src/index.js'])
.pipe(webpack(webpackConfig))
.pipe(header(banner, { pkg }))
.pipe(gulp.dest('./lib/'))
);
gulp.task('build-style', () =>
gulp.src('./src/sass/**/*.scss')
.pipe(scsslint())
.pipe(scsslint.failReporter())
.pipe(sass({
outputStyle: 'expanded',
}).on('error', sass.logError))
.pipe(gulp.dest('./lib'))
);
gulp.task('build-examples', ['build-script', 'build-style'], () =>
gulp.src(['./examples/index.js'])
.pipe(webpack(testWebpackConfig))
.pipe(gulp.dest('./examples/compiled/'))
);
gulp.task('watch', () => {
gulp.watch(['./src/js/**/*.js'], ['build-script']);
gulp.watch(['./src/sass/**/*.scss'], ['build-style']);
});
gulp.task('default', ['build-script', 'build-style']);