@@ -6,12 +6,13 @@ import path from 'path';
6
6
import browserify from 'browserify' ;
7
7
import vueify from 'vueify' ;
8
8
import babelify from 'babelify' ;
9
+ import tfilter from 'tfilter' ;
9
10
import modulesify from 'css-modulesify' ;
10
11
import aliasify from 'aliasify' ;
11
12
import source from 'vinyl-source-stream' ;
12
13
import buffer from 'vinyl-buffer' ;
13
14
import { argv } from 'yargs' ;
14
- import { dirs } from './config' ;
15
+ import { dirs , extended } from './config' ;
15
16
import { customSass } from './compilers' ;
16
17
17
18
gulp . task ( 'build:test' , ( ) => gulp . src ( [
@@ -24,6 +25,12 @@ gulp.task('build:test', () => gulp.src([
24
25
. pipe ( gulp . dest ( dirs . buildTest ) ) ) ;
25
26
26
27
gulp . task ( 'build:client' , [ 'copy:client' , 'copy:config:server' ] , ( ) => {
28
+ // Node modules to be included in babel transpilation
29
+ // Use this with ES6 modules for example
30
+ const bModules = [ ] ;
31
+
32
+ if ( extended ) bModules . push ( 'bootstrap-vue/es' ) ;
33
+
27
34
vueify . compiler . applyConfig ( {
28
35
sass : {
29
36
includePaths : [
@@ -36,13 +43,49 @@ gulp.task('build:client', ['copy:client', 'copy:config:server'], () => {
36
43
} ) ;
37
44
38
45
const b = browserify ( {
39
- entries : path . resolve ( dirs . srcClient , 'main.js' ) ,
46
+ entries : [
47
+ path . resolve ( dirs . srcClient , 'main.js' ) ,
48
+ ...bModules . map ( mod => path . resolve ( dirs . modules , mod ) ) ,
49
+ ] ,
40
50
debug : true ,
41
51
} ) ;
42
52
53
+ // Transpile .vue
43
54
b . transform ( vueify ) ;
44
55
45
- b . transform ( babelify , { plugins : [ 'transform-runtime' ] } ) ;
56
+ // Babel Settings with module filter
57
+ const bSettings = {
58
+ plugins : [ 'transform-runtime' ] ,
59
+ } ;
60
+
61
+ b . transform ( tfilter (
62
+ babelify ,
63
+ {
64
+ filter : ( filename ) => {
65
+ const exception = bModules . some (
66
+ mod => filename . includes (
67
+ path . resolve ( dirs . modules , mod )
68
+ )
69
+ ) ;
70
+ if ( exception ) {
71
+ // node module
72
+ // console.log('Transpiling module', filename);
73
+ return true ;
74
+ } else if ( ! filename . includes ( dirs . modules ) ) {
75
+ // filter not in node_modules
76
+ // console.log('Transpiling src', filename);
77
+ return true ;
78
+ }
79
+ // console.log('NOT transpiling', filename);
80
+ return false ;
81
+ } ,
82
+ } ,
83
+ {
84
+ ...bSettings ,
85
+ global : true ,
86
+ presets : [ 'env' ] ,
87
+ }
88
+ ) ) ;
46
89
47
90
b . plugin ( modulesify , {
48
91
output : path . resolve (
0 commit comments