diff --git a/quartz/cli/plugin-git-handlers.js b/quartz/cli/plugin-git-handlers.js index 1e7dc3481..bda3acc24 100644 --- a/quartz/cli/plugin-git-handlers.js +++ b/quartz/cli/plugin-git-handlers.js @@ -86,7 +86,24 @@ async function runParallel(items, concurrency, fn) { return results } +/** + * Check whether a plugin's .gitignore excludes dist/. + * When dist/ is gitignored, the plugin cannot ship pre-built output in version + * control (e.g. because it uses tree-shaking) and must always be built locally. + */ +function isDistGitignored(pluginDir) { + const gitignorePath = path.join(pluginDir, ".gitignore") + if (!fs.existsSync(gitignorePath)) return false + + const lines = fs.readFileSync(gitignorePath, "utf-8").split("\n") + return lines.some((line) => { + const trimmed = line.trim() + return trimmed === "dist" || trimmed === "dist/" || trimmed === "/dist" || trimmed === "/dist/" + }) +} + function needsBuild(pluginDir) { + if (isDistGitignored(pluginDir)) return true const distDir = path.join(pluginDir, "dist") return !fs.existsSync(distDir) }