-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
108 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es6: true, | ||
node: true | ||
}, | ||
extends: [ | ||
'standard', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
plugins: [ | ||
'@typescript-eslint' | ||
], | ||
parserOptions: { | ||
ecmaVersion: 2022 | ||
}, | ||
rules: { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ npm-debug.log* | |
*.js | ||
pnpm-lock.yaml | ||
.idea | ||
*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import type Hexo from "hexo"; | ||
import {isExclude} from "./utils"; | ||
import browserslist from 'browserslist'; | ||
import {transform,browserslistToTargets} from 'lightningcss' | ||
import type Hexo from 'hexo' | ||
import { isExclude } from './utils' | ||
import browserslist from 'browserslist' | ||
import { transform, browserslistToTargets } from 'lightningcss' | ||
interface CSSMinifyConfig { | ||
enable: boolean | ||
options: { | ||
targets?: string | ||
} | ||
exclude: string[] | ||
} | ||
export function minify_css(this: Hexo,str:string,data:any){ | ||
const {options,exclude} = this.config.minify.css as CSSMinifyConfig | ||
export function minifyCss (this: Hexo, str:string, data:any) { | ||
const { options, exclude } = this.config.minify.css as CSSMinifyConfig | ||
const targets = browserslistToTargets(browserslist(options.targets || '>= 0.5%')) | ||
if (!data.path || isExclude(data.path,exclude)) return str | ||
if (isExclude(data.path, exclude)) return str | ||
return transform({ | ||
filename: data.path, | ||
code: Buffer.from(str), | ||
minify: true, | ||
targets: targets | ||
targets | ||
}).code.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import {transform} from 'esbuild' | ||
import type Hexo from "hexo"; | ||
import {isExclude} from "./utils"; | ||
|
||
import { transform } from 'esbuild' | ||
import type Hexo from 'hexo' | ||
import { isExclude } from './utils' | ||
|
||
interface JavascriptMinifyConfig { | ||
enable: boolean | ||
options: { | ||
|
||
} | ||
options: unknown | ||
exclude?: string[] | ||
} | ||
export async function minify_js(this: Hexo, str:string,data:any){ | ||
const {options,exclude} = this.config.minify.js as JavascriptMinifyConfig | ||
if (!data.path || isExclude(data.path,exclude)) return str | ||
return (await transform(str,{ | ||
export async function minifyJs (this: Hexo, str:string, data:any) { | ||
const { exclude } = this.config.minify.js as JavascriptMinifyConfig | ||
if (isExclude(data.path, exclude)) return str | ||
return (await transform(str, { | ||
minify: true | ||
})).code | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import micromatch from "micromatch"; | ||
import micromatch from 'micromatch' | ||
|
||
export function isExclude(path:string,excludes?:string[]):undefined | boolean { | ||
export function isExclude (path:string, excludes?:string[]):undefined | boolean { | ||
return excludes && excludes.some(item => micromatch.isMatch(path, item, { nocase: true })) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters