-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile_new_js
53 lines (46 loc) · 1.58 KB
/
gulpfile_new_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
// TODO: add task for copy models and package.json in dist + publish from Gulp task
const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const babelify = require('babelify');
const buffer = require('vinyl-buffer');
const uglify = require('gulp-uglify');
const commonShakeify = require('common-shakeify');
gulp.task('buildModule', function() {
return browserify({
entries: './src/initialize.js',
debug: false,
standalone: 'module',
builtins: false,
detectGlobals: false
})
.transform(babelify.configure({
presets: ["@babel/preset-env"]
}))
.plugin(commonShakeify)
.external('@webresto/core/libs/getEmitter')
.external('@webresto/core')
.external('@webresto/graphql/lib/graphqlHelper')
.bundle()
.pipe(source('module.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./dist/dist'));
});
gulp.task('copyModels', function() {
return gulp.src('./models/**/*.js')
.pipe(gulp.dest('./dist/models'));
});
gulp.task('copyTranslates', function() {
return gulp.src('./locales/**/*.json')
.pipe(gulp.dest('./dist/locales'));
});
gulp.task('copyConfig', function() {
return gulp.src('./config/**/*.js')
.pipe(gulp.dest('./dist/config'));
});
gulp.task('copyFiles', function() {
return gulp.src(['./README.md', './index.js', './package.json', './defaults.js', ''])
.pipe(gulp.dest('./dist'));
});
gulp.task('build', gulp.series('buildModule', 'copyModels', 'copyFiles', 'copyTranslates'));