1 | 'use strict';
|
2 |
|
3 |
|
4 | const _CONFIG = (
|
5 | {
|
6 |
|
7 |
|
8 | EntrypointInputSourceFile: `${__dirname}/source/Foxhound-Browser-Shim.js`,
|
9 |
|
10 |
|
11 |
|
12 | LibraryObjectName: `Foxhound`,
|
13 |
|
14 |
|
15 | LibraryOutputFolder: `${__dirname}/dist/`,
|
16 |
|
17 |
|
18 | LibraryUniminifiedFileName: `foxhound.js`,
|
19 |
|
20 |
|
21 | LibraryMinifiedFileName: `foxhound.min.js`
|
22 | });
|
23 |
|
24 |
|
25 |
|
26 | const libBrowserify = require('browserify');
|
27 | const libGulp = require('gulp');
|
28 |
|
29 | const libVinylSourceStream = require('vinyl-source-stream');
|
30 | const libVinylBuffer = require('vinyl-buffer');
|
31 |
|
32 | const libSourcemaps = require('gulp-sourcemaps');
|
33 | const libGulpUtil = require('gulp-util');
|
34 | const libBabel = require('gulp-babel');
|
35 | const libTerser = require('gulp-terser');
|
36 |
|
37 |
|
38 | libGulp.task('minified',
|
39 | () => {
|
40 |
|
41 | var tmpBrowserify = libBrowserify(
|
42 | {
|
43 | entries: _CONFIG.EntrypointInputSourceFile,
|
44 | standalone: _CONFIG.LibraryObjectName,
|
45 | debug: true
|
46 | });
|
47 |
|
48 | return tmpBrowserify.bundle()
|
49 | .pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName))
|
50 | .pipe(libVinylBuffer())
|
51 | .pipe(libSourcemaps.init({loadMaps: true}))
|
52 |
|
53 | .pipe(libBabel())
|
54 | .pipe(libTerser())
|
55 | .on('error', libGulpUtil.log)
|
56 | .pipe(libSourcemaps.write('./'))
|
57 | .pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
58 | });
|
59 |
|
60 |
|
61 | libGulp.task('debug',
|
62 | () => {
|
63 |
|
64 | var tmpBrowserify = libBrowserify(
|
65 | {
|
66 | entries: _CONFIG.EntrypointInputSourceFile,
|
67 | standalone: _CONFIG.LibraryObjectName,
|
68 | debug: true
|
69 | });
|
70 |
|
71 | return tmpBrowserify.bundle()
|
72 | .pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName))
|
73 | .pipe(libVinylBuffer())
|
74 | .pipe(libBabel())
|
75 | .on('error', libGulpUtil.log)
|
76 | .pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
77 | });
|
78 |
|
79 | libGulp.task
|
80 | (
|
81 | 'build',
|
82 | libGulp.series('debug', 'minified')
|
83 | ); |
\ | No newline at end of file |