Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"实现排除页面路径功能以忽略特定页面的链接处理" #1

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

xyhcode
Copy link
Contributor

@xyhcode xyhcode commented Aug 15, 2024

No description provided.

@xyhcode
Copy link
Contributor Author

xyhcode commented Aug 15, 2024

忘记改 package.json 版本了

@willow-god
Copy link
Owner

没事,我检查一下,没问题的话合并了我来改

@willow-god willow-god merged commit 4e68c70 into willow-god:main Aug 15, 2024
@xyhcode
Copy link
Contributor Author

xyhcode commented Aug 20, 2024

没事,我检查一下,没问题的话合并了我来改

还有问题 使用gulp压缩就会报错 不知道为什么
image

@willow-god
Copy link
Owner

我也用了gulp,但是我没有出现问题

@willow-god
Copy link
Owner

我也用了gulp,但是我没有出现问题

image

@xyhcode
Copy link
Contributor Author

xyhcode commented Aug 20, 2024

我也用了gulp,但是我没有出现问题

var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var htmlmin = require('gulp-html-minifier-terser');
var htmlclean = require('gulp-htmlclean');
var uglify = require('gulp-uglify')
var babel = require('gulp-babel')
// 压缩js
gulp.task('compress', () =>
    gulp.src(['./public/**/*.js', '!./public/**/*.min.js'])
        .pipe(babel({
            presets: ['@babel/preset-env']
        }))
        .pipe(uglify().on('error', function (e) {
            console.log(e)
        }))
        .pipe(gulp.dest('./public'))
)
// 压缩css
gulp.task('minify-css', () => {
    return gulp.src(['./public/**/*.css'])
        .pipe(cleanCSS({
            compatibility: 'ie11'
        }))
        .pipe(gulp.dest('./public'));
});
// 压缩html
gulp.task('minify-html', () => {
    return gulp.src('./public/**/*.html')
        .pipe(htmlclean())
        .pipe(htmlmin({
            removeComments: true, 	  // 清除 html 注释
            collapseWhitespace: true, // 压缩 html
            collapseBooleanAttributes: true,
            // 省略布尔属性的值,例如:<input checked="true"/> ==> <input />
            removeEmptyAttributes: true,
            // 删除所有空格作属性值,例如:<input id="" /> ==> <input />
            removeScriptTypeAttributes: true,
            // 删除<script>的type="text/javascript"
            removeStyleLinkTypeAttributes: true,
            // 删除<style>和<link>的 type="text/css"
            minifyJS: true, 	// 压缩页面 JS
            minifyCSS: true, 	// 压缩页面 CSS
            minifyURLs: true 	// 压缩页面 URL
        }))
        .pipe(gulp.dest('./public'))
});

// 运行gulp命令时依次执行以下任务
gulp.task('default', gulp.parallel(
    'compress', 'minify-css', 'minify-html'
))

除非是要gulp-htmlmin 但是gulp-htmlmin没有这个压缩的好

@willow-god
Copy link
Owner

插件的作用仅仅是扫描a标签并且替换链接,并没有破坏html的结构,我感觉和插件没关系
并且我用的就是gulp-html,和你是一样的
image

@xyhcode
Copy link
Contributor Author

xyhcode commented Aug 20, 2024

插件的作用仅仅是扫描a标签并且替换链接,并没有破坏html的结构,我感觉和插件没关系 并且我用的就是gulp-html,和你是一样的 image

你导入用的哪个包 我把这个hexo-safego插件关闭就没有问题了

@willow-god
Copy link
Owner

导入什么

@willow-god willow-god added the enhancement New feature or request label Aug 20, 2024
@xyhcode
Copy link
Contributor Author

xyhcode commented Aug 29, 2024

导入什么

没事 我解决了 换了一种写法就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants