This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
gulpfile.js
58 lines (50 loc) · 1.54 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
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const del = require('del');
const gulpNSP = require('gulp-nsp');
const webpack = require('webpack-stream');
const WebpackDevServer = require( 'webpack-dev-server');
const webpackConfig = require('./webpack.config');
const DEST = './dist/';
// Lint the JS code
gulp.task('lint', [], function(){
return gulp.src(['**/*.js','!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
});
// Remove existing dist folder
gulp.task('clean', ['lint'], function(cb) {
del([DEST]).then(cb.bind(null, null));
});
// Check for vulns with nsp
gulp.task('nsp', function (cb) {
gulpNSP({package: __dirname + '/package.json'}, cb);
});
gulp.task('dist', ['lint'], () => {
return gulp.src('src/curl.lib.js')
.pipe(webpack({
output: {
filename: 'curl.min.js'
}
}))
.pipe(gulp.dest(DEST))
});
gulp.task('server', ['dist'], function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.devtool = 'eval';
myConfig.debug = true;
// Start a webpack-dev-server
new WebpackDevServer(webpack(myConfig), {
publicPath: '/dist',
stats: {
colors: true
},
hot: true
}).listen(8080, 'localhost', function(err) {
if(err) throw new gutil.PluginError('webpack-dev-server', err);
gutil.log('[webpack-dev-server]', 'http://localhost:8080/webpack-dev-server/index.html');
});
});
gulp.task('default', ['lint', 'clean', 'nsp', 'dist']);