mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 21:53:26 +00:00
perf: speed up page rendering and jekyll build process (#2034)
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Style Lint / stylelint (push) Has been cancelled
Lint Commit Messages / commitlint (push) Has been cancelled
Build and Deploy / build (push) Has been cancelled
Build and Deploy / deploy (push) Has been cancelled
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Style Lint / stylelint (push) Has been cancelled
Lint Commit Messages / commitlint (push) Has been cancelled
Build and Deploy / build (push) Has been cancelled
Build and Deploy / deploy (push) Has been cancelled
- Ensure inline scripts execute after the DOM has fully loaded. - Use Rollup to bundle the theme-mode and Mermaid scripts, reducing the number of Jekyll include snippets.
This commit is contained in:
@@ -34,24 +34,32 @@ function insertFrontmatter() {
|
||||
};
|
||||
}
|
||||
|
||||
function build(filename, { src = SRC_DEFAULT, jekyll = false } = {}) {
|
||||
function build(
|
||||
filename,
|
||||
{ src = SRC_DEFAULT, jekyll = false, outputName = null } = {}
|
||||
) {
|
||||
const input = `${src}/${filename}.js`;
|
||||
|
||||
return {
|
||||
input: `${src}/${filename}.js`,
|
||||
input,
|
||||
output: {
|
||||
file: `${DIST}/${filename}.min.js`,
|
||||
format: 'iife',
|
||||
name: 'Chirpy',
|
||||
...(outputName !== null && { name: outputName }),
|
||||
banner,
|
||||
sourcemap: !isProd && !jekyll
|
||||
},
|
||||
watch: {
|
||||
include: `${src}/**`
|
||||
include: input
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
presets: ['@babel/env'],
|
||||
plugins: ['@babel/plugin-transform-class-properties']
|
||||
plugins: [
|
||||
'@babel/plugin-transform-class-properties',
|
||||
'@babel/plugin-transform-private-methods'
|
||||
]
|
||||
}),
|
||||
nodeResolve(),
|
||||
isProd && terser(),
|
||||
@@ -69,6 +77,7 @@ export default [
|
||||
build('page'),
|
||||
build('post'),
|
||||
build('misc'),
|
||||
build('theme', { src: `${SRC_DEFAULT}/modules`, outputName: 'Theme' }),
|
||||
build('app', { src: SRC_PWA, jekyll: true }),
|
||||
build('sw', { src: SRC_PWA, jekyll: true })
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user