1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-04 14:13:28 +01:00
bitwarden-server/src/Admin/gulpfile.js

87 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-03-23 20:07:17 +01:00
/// <binding BeforeBuild='build' Clean='clean' ProjectOpened='build' />
const gulp = require('gulp');
const merge = require('merge-stream');
const googleWebFonts = require('gulp-google-webfonts');
const sass = require('gulp-sass');
const del = require('del');
2018-03-23 20:07:17 +01:00
const paths = {};
paths.webroot = './wwwroot/';
paths.npmDir = './node_modules/';
paths.sassDir = './Sass/';
paths.libDir = paths.webroot + 'lib/';
paths.cssDir = paths.webroot + 'css/';
paths.jsDir = paths.webroot + 'js/';
paths.sass = paths.sassDir + '**/*.scss';
paths.minCss = paths.cssDir + '**/*.min.css';
paths.js = paths.jsDir + '**/*.js';
paths.minJs = paths.jsDir + '**/*.min.js';
paths.libJs = paths.libDir + '**/*.js';
paths.libMinJs = paths.libDir + '**/*.min.js';
function clean() {
return del([paths.minJs, paths.cssDir, paths.libDir]);
}
2018-03-23 20:07:17 +01:00
function lib() {
2018-03-23 20:07:17 +01:00
const libs = [
{
src: paths.npmDir + 'bootstrap/dist/js/*',
dest: paths.libDir + 'bootstrap/js'
},
{
2018-09-11 19:29:55 +02:00
src: paths.npmDir + 'popper.js/dist/umd/*',
2018-03-23 20:07:17 +01:00
dest: paths.libDir + 'popper'
},
{
src: paths.npmDir + 'font-awesome/css/*',
dest: paths.libDir + 'font-awesome/css'
},
{
src: paths.npmDir + 'font-awesome/fonts/*',
dest: paths.libDir + 'font-awesome/fonts'
},
{
src: paths.npmDir + 'jquery/dist/jquery.*',
2018-03-23 20:07:17 +01:00
dest: paths.libDir + 'jquery'
},
{
src: paths.npmDir + 'toastr/build/*',
dest: paths.libDir + 'toastr'
},
2018-03-23 20:07:17 +01:00
];
const tasks = libs.map((lib) => {
return gulp.src(lib.src).pipe(gulp.dest(lib.dest));
});
return merge(tasks);
}
2018-03-23 20:07:17 +01:00
function runSass() {
2018-03-23 20:07:17 +01:00
return gulp.src(paths.sass)
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(gulp.dest(paths.cssDir));
}
2018-03-23 20:07:17 +01:00
function sassWatch() {
gulp.watch(paths.sass, runSass);
}
2018-03-23 20:07:17 +01:00
function webfonts() {
2018-03-23 20:51:54 +01:00
return gulp.src('./webfonts.list')
.pipe(googleWebFonts({
fontsDir: 'webfonts',
cssFilename: 'webfonts.css'
}))
.pipe(gulp.dest(paths.cssDir));
}
2018-03-23 20:51:54 +01:00
exports.build = gulp.series(clean, gulp.parallel([lib, runSass, webfonts]));
exports['sass:watch'] = sassWatch;
exports.sass = runSass;
exports.lib = lib;
exports.webfonts = webfonts;
exports.clean = clean;