@@ -4,6 +4,7 @@ const sass = require('node-sass');
4
4
const browserify = require ( 'browserify' ) ;
5
5
const coffeeify = require ( 'coffeeify' ) ;
6
6
const babelify = require ( 'babelify' ) ;
7
+ const uglifyify = require ( 'uglifyify' ) ;
7
8
const tildeImporter = require ( 'node-sass-tilde-importer' ) ;
8
9
9
10
const paths = {
@@ -13,19 +14,35 @@ const paths = {
13
14
} ,
14
15
output : {
15
16
styles : 'build' ,
16
- scripts : 'build'
17
+ scripts : 'build' ,
18
+ fonts : 'build'
17
19
}
18
20
} ;
19
21
20
- function walkDir ( dir , callback ) {
21
- fs . readdirSync ( dir ) . forEach ( f => {
22
- let dirPath = path . join ( dir , f ) ;
23
- let isDirectory = fs . statSync ( dirPath ) . isDirectory ( ) ;
24
- isDirectory
25
- ? walkDir ( dirPath , callback )
26
- : callback ( path . join ( dir , f ) ) ;
27
- } ) ;
28
- }
22
+ const staticDeps = [
23
+ [ 'node_modules/bootstrap-table/dist/bootstrap-table.min.css' , paths . output . styles ] ,
24
+ [ 'node_modules/chosen-js/chosen.min.css' , paths . output . styles ] ,
25
+ [ 'node_modules/@devhau/md-editor/dist/md-editor.min.css' , paths . output . styles ] ,
26
+
27
+ [ 'node_modules/jquery/dist/jquery.min.js' , paths . output . scripts ] ,
28
+ [ 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js' , paths . output . scripts ] ,
29
+ [ 'node_modules/bootstrap-table/dist/bootstrap-table.min.js' , paths . output . scripts ] ,
30
+ [ 'node_modules/bootstrap-table/dist/extensions/editable/bootstrap-table-editable.min.js' , paths . output . scripts ] ,
31
+ [ 'node_modules/bootstrap-table/dist/locale/bootstrap-table-en-US.min.js' , paths . output . scripts ] ,
32
+ [ 'node_modules/underscore/underscore-min.js' , paths . output . scripts ] ,
33
+ [ 'node_modules/jscroll/dist/jquery.jscroll.min.js' , paths . output . scripts ] ,
34
+ [ 'node_modules/chosen-js/chosen.jquery.min.js' , paths . output . scripts ] ,
35
+ [ 'node_modules/@devhau/md-editor/dist/md-editor.min.js' , paths . output . scripts ] ,
36
+ [ 'node_modules/typeahead.js/dist/typeahead.bundle.min.js' , paths . output . scripts ] ,
37
+
38
+ [ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot' , paths . output . fonts ] ,
39
+ [ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg' , paths . output . fonts ] ,
40
+ [ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf' , paths . output . fonts ] ,
41
+ [ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff' , paths . output . fonts ] ,
42
+ [ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2' , paths . output . fonts ] ,
43
+ [ 'node_modules/font-awesome/fonts/fontawesome-webfont.ttf' , paths . output . fonts ] ,
44
+ [ 'node_modules/font-awesome/fonts/fontawesome-webfont.woff2' , paths . output . fonts ]
45
+ ] ;
29
46
30
47
for ( let path in paths . output ) {
31
48
if ( paths . output . hasOwnProperty ( path ) ) {
@@ -37,6 +54,24 @@ for (let path in paths.output) {
37
54
}
38
55
}
39
56
57
+ for ( const [ fromFile , toDir ] of staticDeps ) {
58
+ const toFile = fs . statSync ( toDir ) . isDirectory ( )
59
+ ? path . join ( toDir , path . basename ( fromFile ) )
60
+ : toDir ;
61
+ fs . copyFileSync ( fromFile , toFile ) ;
62
+ console . log ( `Copied ${ fromFile } to ${ toFile } ` ) ;
63
+ }
64
+
65
+ function walkDir ( dir , callback ) {
66
+ fs . readdirSync ( dir ) . forEach ( f => {
67
+ let dirPath = path . join ( dir , f ) ;
68
+ let isDirectory = fs . statSync ( dirPath ) . isDirectory ( ) ;
69
+ isDirectory
70
+ ? walkDir ( dirPath , callback )
71
+ : callback ( path . join ( dir , f ) ) ;
72
+ } ) ;
73
+ }
74
+
40
75
walkDir ( paths . input . styles , inputFile => {
41
76
if ( ! inputFile . endsWith ( '.scss' ) )
42
77
return ;
@@ -46,19 +81,20 @@ walkDir(paths.input.styles, inputFile => {
46
81
sass . render ( {
47
82
file : inputFile ,
48
83
outfile : outFile ,
84
+ outputStyle : 'compressed' ,
49
85
importer : tildeImporter ,
50
86
} , ( err , result ) => {
51
- if ( err )
87
+ if ( err ) {
52
88
console . log ( err ) ;
53
- else fs . writeFile ( outFile ,
54
- result . css ,
55
- 'utf8' ,
56
- err => {
57
- if ( err )
89
+ } else {
90
+ fs . writeFile ( outFile , result . css , 'utf8' , err => {
91
+ if ( err ) {
58
92
console . log ( err ) ;
59
- else
93
+ } else {
60
94
console . log ( `Rendered ${ inputFile } to ${ outFile } ` ) ;
95
+ }
61
96
} ) ;
97
+ }
62
98
} ) ;
63
99
} ) ;
64
100
@@ -70,7 +106,7 @@ walkDir(paths.input.scripts, inputFile => {
70
106
const outFile = path . join ( paths . output . scripts , `${ basename } .js` ) ;
71
107
browserify ( [ inputFile ] , {
72
108
extensions : [ '.js' , '.coffee' ] ,
73
- transform : [ coffeeify , babelify ] ,
109
+ transform : [ coffeeify , babelify , [ uglifyify , { global : true } ] ] ,
74
110
} ) . bundle ( ( err , result ) => {
75
111
if ( err ) {
76
112
console . log ( err ) ;
0 commit comments