Skip to content

Commit

Permalink
Add gulp support (not fully working yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
hifocus committed Oct 8, 2022
1 parent 2ece0f3 commit 472476e
Show file tree
Hide file tree
Showing 7 changed files with 11,364 additions and 218 deletions.
1 change: 1 addition & 0 deletions assets/bundles/function.main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/bundles/style.main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const gulp = require('gulp');
const terser = require('gulp-terser');
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const htmlmin = require('gulp-html-minifier-terser');
const rename = require('gulp-rename');
const htmlreplace = require('gulp-html-replace');


gulp.task('pack-css', async function () {
return gulp.src(['./assets/styles/spectre.css/spectre-modified.css', './assets/styles/style.css'])
.pipe(concat('style.main.css'))
.pipe(cleanCSS({
level: 2
}))
.pipe(gulp.dest('./assets/bundles/'))
.pipe(gulp.dest('./dist/assets/'));
});

gulp.task('pack-js', async function() {
gulp.src(['./assets/js/function.js', './assets/js/iconfont.js'])
.pipe(concat('function.main.js'))
.pipe(terser())
.pipe(gulp.dest('./assets/bundles/'))
.pipe(gulp.dest('./dist/assets/'));
});

gulp.task('minify-html', async function() {
gulp.src(['./build/merger.html'])
.pipe(htmlmin({
collapseWhitespace: true,
conservativeCollapse: true,
collapseInlineTagWhitespace: true,
collapseBooleanAttributes: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
sortAttributes: true,
sortClassName: true,
}))
.pipe(rename('index.html'))
.pipe(gulp.dest('build/'));
});

gulp.task('replace-js-css', async function() {
gulp.src('./merger.html')
.pipe(htmlreplace({
'css': '/assets/style.main.css',
'js': '/assets/function.main.js'
}))
// .pipe(rename('index.html'))
.pipe(gulp.dest('build/'))
});

gulp.task('compile', gulp.parallel('pack-css', 'pack-js'));
gulp.task('default', gulp.series('replace-js-css', 'minify-html'));
12 changes: 7 additions & 5 deletions merger.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
<link rel="shortcut icon" type="image/x-icon" id="favicon"><!-- Page icon will be set automatically -->

<!-- Load style files from local - Default -->
<link rel="stylesheet" href="/assets/styles/spectre.css/spectre-modified.min.css">
<link rel="stylesheet" href="/assets/styles/style.css">
<!-- build:css -->
<link rel="stylesheet" href="/assets/bundles/style.main.css">
<!-- endbuild -->
</head>

<body>
Expand Down Expand Up @@ -169,9 +170,10 @@ <h2 id="name"></h2>
type="application/javascript"></script>
<script src="https://s1.pstatp.com/cdn/expire-1-M/lrsjng.jquery-qrcode/0.18.0/jquery-qrcode.min.js"
type="application/javascript"></script>
<script src="/assets/js/function.js"></script>
<script src="/assets/js/font_974919_xgtacm93vxp.js"></script>

<!-- build:js -->
<script src="/assets/bundles/function.main.js"></script>
<!-- endbuild -->

<!-- Static files of this project is available on CDNJS and respective mirror sites
https://cdnjs.com/libraries/merger
https://cdn.baomitu.com/merger
Expand Down
Loading

0 comments on commit 472476e

Please sign in to comment.