|
|
@ -6,15 +6,17 @@
|
|
|
|
const browserSync = require('browser-sync').create()
|
|
|
|
const browserSync = require('browser-sync').create()
|
|
|
|
const cleanCss = require('gulp-clean-css')
|
|
|
|
const cleanCss = require('gulp-clean-css')
|
|
|
|
const del = require('del')
|
|
|
|
const del = require('del')
|
|
|
|
const gulp = require('gulp')
|
|
|
|
const esbuild = require('esbuild')
|
|
|
|
|
|
|
|
const { ESLint } = require('eslint')
|
|
|
|
|
|
|
|
const { src, dest, lastRun, watch, series } = require('gulp')
|
|
|
|
|
|
|
|
const fileinclude = require('gulp-file-include')
|
|
|
|
const npmDist = require('gulp-npm-dist')
|
|
|
|
const npmDist = require('gulp-npm-dist')
|
|
|
|
const sass = require('gulp-sass')
|
|
|
|
|
|
|
|
const wait = require('gulp-wait')
|
|
|
|
|
|
|
|
const postcss = require('gulp-postcss')
|
|
|
|
const postcss = require('gulp-postcss')
|
|
|
|
const rename = require('gulp-rename')
|
|
|
|
const rename = require('gulp-rename')
|
|
|
|
|
|
|
|
const sass = require('gulp-sass')
|
|
|
|
const sourcemaps = require('gulp-sourcemaps')
|
|
|
|
const sourcemaps = require('gulp-sourcemaps')
|
|
|
|
const fileinclude = require('gulp-file-include')
|
|
|
|
const gulpStylelint = require('gulp-stylelint')
|
|
|
|
const esbuild = require('esbuild')
|
|
|
|
const wait = require('gulp-wait')
|
|
|
|
|
|
|
|
|
|
|
|
sass.compiler = require('sass')
|
|
|
|
sass.compiler = require('sass')
|
|
|
|
|
|
|
|
|
|
|
@ -100,18 +102,28 @@ function postcssRtlOptions() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Compile SCSS
|
|
|
|
// Compile SCSS
|
|
|
|
gulp.task('scss', () => {
|
|
|
|
const scss = () => {
|
|
|
|
return gulp.src(paths.src.scss + '/adminlte.scss')
|
|
|
|
return src(paths.src.scss + '/adminlte.scss')
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest(paths.temp.css))
|
|
|
|
.pipe(dest(paths.temp.css))
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('ts', () => {
|
|
|
|
// Lint SCSS
|
|
|
|
|
|
|
|
const lintScss = () => {
|
|
|
|
|
|
|
|
return src([paths.src.scss + '/**/*.scss'], { since: lastRun(lintScss) })
|
|
|
|
|
|
|
|
.pipe(gulpStylelint({
|
|
|
|
|
|
|
|
reporters: [
|
|
|
|
|
|
|
|
{ formatter: 'string', console: true }
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ts = () => {
|
|
|
|
return esbuild.build({
|
|
|
|
return esbuild.build({
|
|
|
|
entryPoints: [paths.src.ts + '/adminlte.ts'],
|
|
|
|
entryPoints: [paths.src.ts + '/adminlte.ts'],
|
|
|
|
banner: {
|
|
|
|
banner: {
|
|
|
@ -125,10 +137,19 @@ gulp.task('ts', () => {
|
|
|
|
}).catch(
|
|
|
|
}).catch(
|
|
|
|
error => console.error(error)
|
|
|
|
error => console.error(error)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('index', () => {
|
|
|
|
// Lint TS
|
|
|
|
return gulp.src([paths.src.base + '*.html'])
|
|
|
|
async function lintTs() {
|
|
|
|
|
|
|
|
const eslint = new ESLint()
|
|
|
|
|
|
|
|
const results = await eslint.lintFiles([paths.src.ts + '/**/*.ts'])
|
|
|
|
|
|
|
|
const formatter = await eslint.loadFormatter('stylish')
|
|
|
|
|
|
|
|
const resultText = formatter.format(results)
|
|
|
|
|
|
|
|
console.log(resultText)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const index = () => {
|
|
|
|
|
|
|
|
return src([paths.src.base + '*.html'])
|
|
|
|
.pipe(fileinclude({
|
|
|
|
.pipe(fileinclude({
|
|
|
|
prefix: '@@',
|
|
|
|
prefix: '@@',
|
|
|
|
basepath: './src/partials/',
|
|
|
|
basepath: './src/partials/',
|
|
|
@ -136,12 +157,12 @@ gulp.task('index', () => {
|
|
|
|
environment: 'development'
|
|
|
|
environment: 'development'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(paths.temp.base))
|
|
|
|
.pipe(dest(paths.temp.base))
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('html', () => {
|
|
|
|
const html = () => {
|
|
|
|
return gulp.src([paths.src.html])
|
|
|
|
return src([paths.src.html])
|
|
|
|
.pipe(fileinclude({
|
|
|
|
.pipe(fileinclude({
|
|
|
|
prefix: '@@',
|
|
|
|
prefix: '@@',
|
|
|
|
basepath: './src/partials/',
|
|
|
|
basepath: './src/partials/',
|
|
|
@ -149,47 +170,48 @@ gulp.task('html', () => {
|
|
|
|
environment: 'development'
|
|
|
|
environment: 'development'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(paths.temp.html))
|
|
|
|
.pipe(dest(paths.temp.html))
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('assets', () => {
|
|
|
|
const assets = () => {
|
|
|
|
return gulp.src([paths.src.assets])
|
|
|
|
return src([paths.src.assets])
|
|
|
|
.pipe(gulp.dest(paths.temp.assets))
|
|
|
|
.pipe(dest(paths.temp.assets))
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
.pipe(browserSync.stream())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('vendor', () => {
|
|
|
|
const vendor = () => {
|
|
|
|
return gulp.src(npmDist(), { base: paths.src.node_modules })
|
|
|
|
return src(npmDist({ copyUnminified: true }), { base: paths.src.node_modules })
|
|
|
|
.pipe(gulp.dest(paths.temp.vendor))
|
|
|
|
.pipe(dest(paths.temp.vendor))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('serve', gulp.series('scss', 'ts', 'html', 'index', 'assets', 'vendor', () => {
|
|
|
|
const serve = () => {
|
|
|
|
browserSync.init({
|
|
|
|
browserSync.init({
|
|
|
|
server: paths.temp.base
|
|
|
|
server: paths.temp.base
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
gulp.watch([paths.src.scss], gulp.series('scss'))
|
|
|
|
watch([paths.src.scss], series(scss))
|
|
|
|
gulp.watch([paths.src.ts], gulp.series('ts'))
|
|
|
|
watch([paths.src.scss], series(lintScss))
|
|
|
|
gulp.watch([paths.src.html, paths.src.base + '*.html', paths.src.partials], gulp.series('html', 'index'))
|
|
|
|
watch([paths.src.ts], series(ts))
|
|
|
|
gulp.watch([paths.src.assets], gulp.series('assets'))
|
|
|
|
watch([paths.src.html, paths.src.base + '*.html', paths.src.partials], series(html, index))
|
|
|
|
gulp.watch([paths.src.vendor], gulp.series('vendor'))
|
|
|
|
watch([paths.src.assets], series(assets))
|
|
|
|
}))
|
|
|
|
watch([paths.src.vendor], series(vendor))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Minify CSS
|
|
|
|
// Minify CSS
|
|
|
|
gulp.task('minify:dist:css', () => {
|
|
|
|
const minifyDistCss = () => {
|
|
|
|
return gulp.src([
|
|
|
|
return src([
|
|
|
|
paths.dist.css + '/**/*.css'
|
|
|
|
paths.dist.css + '/**/*.css'
|
|
|
|
], { base: paths.dist.css })
|
|
|
|
], { base: paths.dist.css })
|
|
|
|
.pipe(sourcemaps.init({ loadMaps: true }))
|
|
|
|
.pipe(sourcemaps.init({ loadMaps: true }))
|
|
|
|
.pipe(cleanCss())
|
|
|
|
.pipe(cleanCss())
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(rename({ suffix: '.min' }))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest(paths.dist.css))
|
|
|
|
.pipe(dest(paths.dist.css))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Minify JS
|
|
|
|
// Minify JS
|
|
|
|
gulp.task('minify:dist:js', () => {
|
|
|
|
const minifyDistJs = () => {
|
|
|
|
return esbuild.build({
|
|
|
|
return esbuild.build({
|
|
|
|
entryPoints: [paths.dist.js + '/adminlte.js'],
|
|
|
|
entryPoints: [paths.dist.js + '/adminlte.js'],
|
|
|
|
format: 'iife',
|
|
|
|
format: 'iife',
|
|
|
@ -200,42 +222,42 @@ gulp.task('minify:dist:js', () => {
|
|
|
|
}).catch(
|
|
|
|
}).catch(
|
|
|
|
error => console.error(error)
|
|
|
|
error => console.error(error)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy assets
|
|
|
|
// Copy assets
|
|
|
|
gulp.task('copy:dist:assets', () => {
|
|
|
|
const copyDistAssets = () => {
|
|
|
|
return gulp.src(paths.src.assets)
|
|
|
|
return src(paths.src.assets)
|
|
|
|
.pipe(gulp.dest(paths.dist.assets))
|
|
|
|
.pipe(dest(paths.dist.assets))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Clean
|
|
|
|
// Clean
|
|
|
|
gulp.task('clean:dist', () => {
|
|
|
|
const cleanDist = () => {
|
|
|
|
return del([paths.dist.base])
|
|
|
|
return del([paths.dist.base])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Compile and copy scss/css
|
|
|
|
// Compile and copy scss/css
|
|
|
|
gulp.task('copy:dist:css', () => {
|
|
|
|
const copyDistCss = () => {
|
|
|
|
return gulp.src([paths.src.scss + '/adminlte.scss'])
|
|
|
|
return src([paths.src.scss + '/adminlte.scss'])
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest(paths.dist.css))
|
|
|
|
.pipe(dest(paths.dist.css))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('copy:dist:css:dark', () => {
|
|
|
|
const copyDistCssDark = () => {
|
|
|
|
return gulp.src([paths.src.scss + '/dark/*.scss'])
|
|
|
|
return src([paths.src.scss + '/dark/*.scss'])
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(wait(500))
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(sass(sassOptions).on('error', sass.logError))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(postcss(postcssOptions))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest(paths.dist.css + '/dark'))
|
|
|
|
.pipe(dest(paths.dist.css + '/dark'))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('copy:dist:css:rtl', () => {
|
|
|
|
const copyDistCssRtl = () => {
|
|
|
|
return gulp.src([
|
|
|
|
return src([
|
|
|
|
paths.dist.css + '/*.css',
|
|
|
|
paths.dist.css + '/*.css',
|
|
|
|
paths.dist.css + '/dark/*.css'
|
|
|
|
paths.dist.css + '/dark/*.css'
|
|
|
|
])
|
|
|
|
])
|
|
|
@ -244,11 +266,11 @@ gulp.task('copy:dist:css:rtl', () => {
|
|
|
|
.pipe(postcss(postcssRtlOptions))
|
|
|
|
.pipe(postcss(postcssRtlOptions))
|
|
|
|
.pipe(rename({ suffix: '.rtl' }))
|
|
|
|
.pipe(rename({ suffix: '.rtl' }))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest(paths.dist.css + '/rtl'))
|
|
|
|
.pipe(dest(paths.dist.css + '/rtl'))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Compile and copy ts/js
|
|
|
|
// Compile and copy ts/js
|
|
|
|
gulp.task('copy:dist:js', () => {
|
|
|
|
const copyDistJs = () => {
|
|
|
|
return esbuild.build({
|
|
|
|
return esbuild.build({
|
|
|
|
entryPoints: [paths.src.ts + '/adminlte.ts'],
|
|
|
|
entryPoints: [paths.src.ts + '/adminlte.ts'],
|
|
|
|
banner: {
|
|
|
|
banner: {
|
|
|
@ -262,11 +284,11 @@ gulp.task('copy:dist:js', () => {
|
|
|
|
}).catch(
|
|
|
|
}).catch(
|
|
|
|
error => console.error(error)
|
|
|
|
error => console.error(error)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy Html
|
|
|
|
// Copy Html
|
|
|
|
gulp.task('copy:dist:html', () => {
|
|
|
|
const copyDistHtml = () => {
|
|
|
|
return gulp.src([paths.src.html])
|
|
|
|
return src([paths.src.html])
|
|
|
|
.pipe(fileinclude({
|
|
|
|
.pipe(fileinclude({
|
|
|
|
prefix: '@@',
|
|
|
|
prefix: '@@',
|
|
|
|
basepath: './src/partials/',
|
|
|
|
basepath: './src/partials/',
|
|
|
@ -274,12 +296,12 @@ gulp.task('copy:dist:html', () => {
|
|
|
|
environment: 'production'
|
|
|
|
environment: 'production'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(paths.dist.html))
|
|
|
|
.pipe(dest(paths.dist.html))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy index
|
|
|
|
// Copy index
|
|
|
|
gulp.task('copy:dist:html:index', () => {
|
|
|
|
const copyDistHtmlIndex = () => {
|
|
|
|
return gulp.src([paths.src.base + '*.html'])
|
|
|
|
return src([paths.src.base + '*.html'])
|
|
|
|
.pipe(fileinclude({
|
|
|
|
.pipe(fileinclude({
|
|
|
|
prefix: '@@',
|
|
|
|
prefix: '@@',
|
|
|
|
basepath: './src/partials/',
|
|
|
|
basepath: './src/partials/',
|
|
|
@ -287,16 +309,16 @@ gulp.task('copy:dist:html:index', () => {
|
|
|
|
environment: 'production'
|
|
|
|
environment: 'production'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(paths.dist.base))
|
|
|
|
.pipe(dest(paths.dist.base))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Copy node_modules to vendor
|
|
|
|
// Copy node_modules to vendor
|
|
|
|
gulp.task('copy:dist:vendor', () => {
|
|
|
|
const copyDistVendor = () => {
|
|
|
|
return gulp.src(npmDist(), { base: paths.src.node_modules })
|
|
|
|
return src(npmDist({ copyUnminified: true }), { base: paths.src.node_modules })
|
|
|
|
.pipe(gulp.dest(paths.dist.vendor))
|
|
|
|
.pipe(dest(paths.dist.vendor))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('build', gulp.series('clean:dist', 'copy:dist:css', 'copy:dist:css:dark', 'copy:dist:css:rtl', 'minify:dist:css', 'copy:dist:js', 'minify:dist:js', 'copy:dist:html', 'copy:dist:html:index', 'copy:dist:assets', 'copy:dist:vendor'))
|
|
|
|
exports.build = series(lintScss, lintTs, cleanDist, copyDistCss, copyDistCssDark, copyDistCssRtl, minifyDistCss, copyDistJs, minifyDistJs, copyDistHtml, copyDistHtmlIndex, copyDistAssets, copyDistVendor)
|
|
|
|
|
|
|
|
|
|
|
|
// Default
|
|
|
|
// Default
|
|
|
|
gulp.task('default', gulp.series('serve'))
|
|
|
|
exports.default = series(lintScss, scss, lintTs, ts, html, index, assets, vendor, serve)
|
|
|
|