Vite Plugin SCORM
raw JSON → 0.0.2 verified Mon Apr 27 auth: no javascript
A Vite plugin (v0.0.2, early release) that packages build output into SCORM-compliant ZIP files for SCORM 1.2 and SCORM 2004 4th Edition. It runs during the closeBundle hook, validates course metadata, and generates imsmanifest.xml with ZIPs. Key differentiator: integrates SCORM packaging into Vite builds with TypeScript support, offering a custom loader for non-Svelte projects. Currently limited to single SCO packages with no sequencing or navigation rules.
Common errors
error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'vite-plugin-scorm' ↓
cause Package not installed or version incompatible.
fix
Run
npm install vite-plugin-scorm and ensure vite >= 5.0.0 is installed. error TypeError: scormPackager is not a function ↓
cause Using wrong import (default import instead of named import).
fix
Use
import { scormPackager } from 'vite-plugin-scorm'; error [vite-plugin-scorm] Missing required course metadata: 'id' ↓
cause Course metadata object in course file lacks required fields (id, title, minScore, maxScore).
fix
Ensure the exported
course object includes all required fields. Example: { id: 'c1', title: 'Test', minScore: 0, maxScore: 100 } Warnings
gotcha The default course file is set to 'src/course.ts'. If absent, the build may fail silently if no custom loadCourse is provided. ↓
fix Ensure src/course.ts exists with proper CourseMetadata export, or provide a loadCourse function.
gotcha Course metadata is static at build time. Dynamic runtime updates (e.g., score changes) are not supported. ↓
fix All metadata must be defined at build time; no runtime modification possible.
gotcha The plugin runs during the closeBundle hook, meaning it cannot be used during dev server. Only works with vite build. ↓
fix Use only for production builds; ignore SCORM packaging during vite dev.
gotcha All build output files are included in the SCORM ZIP. There is no selective file inclusion/exclusion option. ↓
fix Remove unwanted files from build output before packaging or implement a custom solution.
Install
npm install vite-plugin-scorm yarn add vite-plugin-scorm pnpm add vite-plugin-scorm Imports
- scormPackager wrong
import scormPackager from 'vite-plugin-scorm'; -- default export not availablecorrectimport { scormPackager } from 'vite-plugin-scorm' - ScormPackagerOptions
import type { ScormPackagerOptions } from 'vite-plugin-scorm' - CourseMetadata
import type { CourseMetadata } from 'vite-plugin-scorm'
Quickstart
// vite.config.ts
import { defineConfig } from 'vite';
import { scormPackager } from 'vite-plugin-scorm';
export default defineConfig({
plugins: [
scormPackager({
courseFile: 'src/course.ts',
target: 'both',
}),
],
});
// src/course.ts
export const course = {
id: 'course-1',
title: 'My Course',
description: 'An example course',
masteryScore: 80,
minScore: 0,
maxScore: 100,
};