diff --git a/rollup.config.js b/rollup.config.js
index 9a8b5a17..cb0b7e62 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,4 +1,5 @@
 import commonjs from '@rollup/plugin-commonjs';
+import fs from 'node:fs';
 import image from '@rollup/plugin-image';
 import json from '@rollup/plugin-json';
 import { nodeResolve } from '@rollup/plugin-node-resolve';
@@ -27,11 +28,16 @@ const serveopts = {
   },
 };
 
+const hasDotGit = fs.existsSync('git');
+const gitInfoPlugin = hasDotGit
+  ? [gitInfo.default({ enableBuildDate: true, updateVersion: false })]
+  : [];
+
 /**
  * @type {import('rollup').RollupOptions['plugins']}
  */
 const plugins = [
-  gitInfo.default({ enableBuildDate: true, updateVersion: false }),
+  ...gitInfoPlugin,
   styles({
     modules: false,
     // Behavior of inject mode, without actually injecting style
@@ -55,7 +61,7 @@ const plugins = [
     inlineSources: dev,
     exclude: ['dist/**', 'tests/**/*.test.ts'],
   }),
-  json({ exclude: 'package.json' }),
+  json({ exclude: hasDotGit ? 'package.json' : undefined }),
   replace({
     preventAssignment: true,
     values: {
