Lines 10-16
try {
Link Here
|
10 |
process.exit(1); |
10 |
process.exit(1); |
11 |
} |
11 |
} |
12 |
|
12 |
|
|
|
13 |
const browserify = require( "browserify" ); |
13 |
const gutil = require( "gulp-util" ); |
14 |
const gutil = require( "gulp-util" ); |
|
|
15 |
const source = require( "vinyl-source-stream" ); |
16 |
const tap = require( "gulp-tap" ); |
14 |
const sass = require("gulp-sass"); |
17 |
const sass = require("gulp-sass"); |
15 |
const cssnano = require("gulp-cssnano"); |
18 |
const cssnano = require("gulp-cssnano"); |
16 |
const sourcemaps = require('gulp-sourcemaps'); |
19 |
const sourcemaps = require('gulp-sourcemaps'); |
Lines 21-26
const STAFF_CSS_BASE = "koha-tmpl/intranet-tmpl/prog/css";
Link Here
|
21 |
const OPAC_JS_BASE = "koha-tmpl/opac-tmpl/bootstrap/js"; |
24 |
const OPAC_JS_BASE = "koha-tmpl/opac-tmpl/bootstrap/js"; |
22 |
const OPAC_CSS_BASE = "koha-tmpl/opac-tmpl/bootstrap/css"; |
25 |
const OPAC_CSS_BASE = "koha-tmpl/opac-tmpl/bootstrap/css"; |
23 |
|
26 |
|
|
|
27 |
// These node modules will be shoved into vendor.js instead of each built file. |
28 |
const VENDOR_DEPENDENCIES = [ |
29 |
"lodash", |
30 |
"promise-polyfill", |
31 |
"react", |
32 |
"react-dom", |
33 |
"whatwg-fetch", |
34 |
]; |
35 |
|
24 |
var sassOptions = { |
36 |
var sassOptions = { |
25 |
errLogToConsole: true, |
37 |
errLogToConsole: true, |
26 |
precision: 3 |
38 |
precision: 3 |
Lines 58-61
gulp.task('build', function() {
Link Here
|
58 |
|
70 |
|
59 |
gulp.task('watch', function(){ |
71 |
gulp.task('watch', function(){ |
60 |
gulp.watch( css_base + "/src/**/*.scss", ['css'] ); |
72 |
gulp.watch( css_base + "/src/**/*.scss", ['css'] ); |
61 |
}); |
73 |
}); |
|
|
74 |
|
75 |
let vendorBuilt = false; |
76 |
|
77 |
function getBundler() { |
78 |
let bundler = browserify( { |
79 |
debug: !process.env.PRODUCTION, |
80 |
} ); |
81 |
|
82 |
if ( process.env.DESCRIPTION ) { |
83 |
bundler.transform( "uglifyify" ); |
84 |
} |
85 |
|
86 |
return bundler; |
87 |
} |
88 |
|
89 |
gulp.task( "build", () => { |
90 |
if ( !vendorBuilt ) { |
91 |
getBundler().require( VENDOR_DEPENDENCIES ) |
92 |
.bundle() |
93 |
.on( "error", gutil.log ) |
94 |
.pipe( source( "vendor.js" ) ) |
95 |
.pipe( gulp.dest( js_base + "/built/" ) ); |
96 |
} |
97 |
|
98 |
let bundler = getBundler().transform( "babelify", { presets: [ "es2015", "react" ], plugins: [ "transform-class-properties" ] } ); |
99 |
|
100 |
return gulp.src( js_base + '/src/**/entry.js' ) |
101 |
.pipe( tap( file => { |
102 |
let base_start = file.path.indexOf( js_base ); |
103 |
gutil.log( `bundling ${file.path.substr( base_start + js_base.length + 1 )}` ); |
104 |
|
105 |
bundler.external( VENDOR_DEPENDENCIES ); |
106 |
file.contents = bundler.add( file.path ).bundle(); |
107 |
} ) ) |
108 |
.pipe( gulp.dest( js_base+ "/built" ) ); |
109 |
} ); |