diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index b11f99069..0df4d7375 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -29,22 +29,30 @@ jobs: - name: Install dependencies run: npm ci - - name: Build distribution + - name: Build full distribution run: npm run build + - name: Build simple distribution + run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run build + - name: Extract version id: version run: | VERSION=${GITHUB_REF#refs/tags/v} echo "version=${VERSION}" >> $GITHUB_OUTPUT - - name: Package distribution + - name: Package full distribution run: npm run package + - name: Package simple distribution + run: BUILD_OUTPUT_DIR=dist-simple npm run package + - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - files: dist-${{ steps.version.outputs.version }}.zip + files: | + dist-${{ steps.version.outputs.version }}.zip + dist-simple-${{ steps.version.outputs.version }}.zip generate_release_notes: true draft: false prerelease: false diff --git a/.gitignore b/.gitignore index a89bf354b..05ee44e47 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ lerna-debug.log* node_modules dist +dist-simple dist-ssr *.local .npm-cache @@ -41,4 +42,4 @@ libreoffice-wasm-package bentopdf-*.tgz # test -dist-test \ No newline at end of file +dist-test diff --git a/eslint.config.mjs b/eslint.config.mjs index d1130f868..d5c766596 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,7 +5,7 @@ import eslintConfigPrettier from "eslint-config-prettier"; export default [ { files: ["**/*.{js,mjs,cjs,ts}"] }, - { ignores: ["dist/**", "coverage/**", "node_modules/**", "**/.vitepress/cache/**", "public/**/*.min.js"] }, + { ignores: ["dist/**", "dist-simple/**", "coverage/**", "node_modules/**", "**/.vitepress/cache/**", "public/**/*.min.js"] }, { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, pluginJs.configs.recommended, ...tseslint.configs.recommended, diff --git a/scripts/package-dist.js b/scripts/package-dist.js index 17c783222..f2bf32b37 100644 --- a/scripts/package-dist.js +++ b/scripts/package-dist.js @@ -8,11 +8,14 @@ import { execSync } from 'child_process'; const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')); const version = packageJson.version; -console.log(`📦 Building dist folder for version ${version}...`); +const buildOutputDirName = process.env.BUILD_OUTPUT_DIR || 'dist'; +console.log(`📦 Building ${buildOutputDirName} folder for version ${version}...`); + +const isSimpleMode = (buildOutputDirName === "dist-simple") ? true : false; // Run the build command try { - execSync('npm run build', { stdio: 'inherit' }); + execSync(`SIMPLE_MODE=${isSimpleMode} npm run build`, { stdio: 'inherit' }); console.log('✅ Build completed successfully'); } catch (error) { console.error('❌ Build failed:', error.message); @@ -25,12 +28,12 @@ import { pipeline } from 'stream'; import { promisify } from 'util'; import archiver from 'archiver'; -const distDir = path.resolve('./dist'); -const zipPath = path.resolve(`./dist-${version}.zip`); +const buildOutputDir = path.resolve(`./${buildOutputDirName}`); +const zipPath = path.resolve(`./${buildOutputDirName}-${version}.zip`); // Check if dist directory exists -if (!existsSync(distDir)) { - console.error('❌ dist directory does not exist. Please run build first.'); +if (!existsSync(buildOutputDir)) { + console.error(`❌ ${buildOutputDirName} directory does not exist. Please run build first.`); process.exit(1); } @@ -55,7 +58,7 @@ archive.on('error', (err) => { archive.pipe(output); // Append the dist directory to the archive -archive.directory(distDir, false); +archive.directory(buildOutputDir, false); // Finalize the archive archive.finalize(); diff --git a/tsconfig.json b/tsconfig.json index c547cafaf..b23f069a6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -56,5 +56,5 @@ } }, "include": ["src", "src/**/*.ts", "public/workers", "vite.config.ts"], // Updated to include all TS files - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "dist-simple"] } diff --git a/vite.config.ts b/vite.config.ts index 5b1e410cb..066a09a50 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -83,6 +83,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction { const basePath = getBasePath(); const [fullPathname, queryString] = req.url.split('?'); + const outputDir = process.env.BUILD_OUTPUT_DIR || 'dist'; let pathname = fullPathname; if (basePath && basePath !== '/' && pathname.startsWith(basePath)) { @@ -114,7 +115,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction { if (isDev) { req.url = '/index.html' + (queryString ? `?${queryString}` : ''); } else { - const langIndexPath = resolve(__dirname, 'dist', lang, 'index.html'); + const langIndexPath = resolve(__dirname, outputDir, lang, 'index.html'); if (fs.existsSync(langIndexPath)) { req.url = `/${lang}/index.html` + (queryString ? `?${queryString}` : ''); @@ -142,7 +143,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction { } else { const langPagePath = resolve( __dirname, - 'dist', + outputDir, lang, `${pageName}.html` ); @@ -162,7 +163,7 @@ function createLanguageMiddleware(isDev: boolean): Connect.NextHandleFunction { } else { const langPagePath = resolve( __dirname, - 'dist', + outputDir, lang, `${cleanPath}.html` ); @@ -367,6 +368,7 @@ export default defineConfig(() => { }, }, build: { + outDir: process.env.BUILD_OUTPUT_DIR || 'dist', rollupOptions: { input: { main: @@ -582,6 +584,7 @@ export default defineConfig(() => { '*.config.ts', '**/*.d.ts', 'dist/', + 'dist-simple/', ], }, }, diff --git a/vitest.config.ts b/vitest.config.ts index d12553b38..f9ab9f0cb 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -21,6 +21,7 @@ export default defineConfig({ 'node_modules/', 'src/tests/', 'dist/', + 'dist-simple/', '*.config.ts', '*.config.js', '**/*.d.ts',