1 Star 0 Fork 0

tanhaiyuan/hypothesis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.mjs 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
Robert Knight 提交于 2021-10-25 17:59 . Sort imports by package path
import {
buildCSS,
buildJS,
generateManifest,
runTests,
watchJS,
} from '@hypothesis/frontend-build';
import gulp from 'gulp';
import changed from 'gulp-changed';
import gulpIf from 'gulp-if';
import svgmin from 'gulp-svgmin';
const IS_PRODUCTION_BUILD = process.env.NODE_ENV === 'production';
gulp.task('build-js', () => buildJS('./rollup.config.mjs'));
gulp.task('watch-js', () => watchJS('./rollup.config.mjs'));
gulp.task('build-css', () =>
buildCSS([
'./node_modules/bootstrap/dist/css/bootstrap.css',
'./h/static/styles/admin.scss',
'./h/static/styles/help-page.scss',
'./h/static/styles/site.scss',
'./h/static/styles/vendor/icomoon.css',
])
);
gulp.task('watch-css', () => {
gulp.watch(
'h/static/styles/**/*.scss',
{ ignoreInitial: false },
gulp.series('build-css')
);
});
const fontFiles = 'h/static/styles/vendor/fonts/h.woff';
gulp.task('build-fonts', () => {
const fontsDir = 'build/fonts';
return gulp.src(fontFiles).pipe(changed(fontsDir)).pipe(gulp.dest(fontsDir));
});
gulp.task('watch-fonts', () => {
gulp.watch(fontFiles, gulp.series('build-fonts'));
});
const imageFiles = 'h/static/images/**/*';
gulp.task('build-images', () => {
const shouldMinifySVG = function (file) {
return IS_PRODUCTION_BUILD && file.path.match(/\.svg$/);
};
// See https://github.com/ben-eb/gulp-svgmin#plugins
const svgminConfig = {
plugins: [
{
// svgo removes `viewBox` by default, which breaks scaled rendering of
// the SVG.
//
// See https://github.com/svg/svgo/issues/1128
name: 'removeViewBox',
active: false,
},
],
};
const imagesDir = 'build/images';
return gulp
.src(imageFiles)
.pipe(changed(imagesDir))
.pipe(gulpIf(shouldMinifySVG, svgmin(svgminConfig)))
.pipe(gulp.dest(imagesDir));
});
gulp.task('watch-images', () => {
gulp.watch(imageFiles, gulp.series('build-images'));
});
const MANIFEST_SOURCE_FILES = 'build/@(fonts|images|scripts|styles)/**/*.*';
gulp.task('build-manifest', () =>
generateManifest({ pattern: MANIFEST_SOURCE_FILES })
);
gulp.task('watch-manifest', () => {
gulp.watch(MANIFEST_SOURCE_FILES, gulp.series('build-manifest'));
});
gulp.task(
'build',
gulp.series(
gulp.parallel(['build-js', 'build-css', 'build-fonts', 'build-images']),
'build-manifest'
)
);
gulp.task(
'watch',
gulp.parallel([
'watch-js',
'watch-css',
'watch-fonts',
'watch-images',
'watch-manifest',
])
);
gulp.task('test', () =>
runTests({
bootstrapFile: './h/static/scripts/tests/bootstrap.js',
karmaConfig: './h/static/scripts/karma.config.js',
rollupConfig: './rollup-tests.config.mjs',
testsPattern: 'h/static/scripts/**/*-test.js',
})
);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/tanhaiyuan/hypothesis.git
[email protected]:tanhaiyuan/hypothesis.git
tanhaiyuan
hypothesis
hypothesis
master

搜索帮助