Skip to content

Commit

Permalink
Update vite config with the new version
Browse files Browse the repository at this point in the history
  • Loading branch information
gparant committed Aug 21, 2024
1 parent 03eab19 commit d22eb45
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
import { defineConfig } from "vite";
import 'dotenv/config';
import { lstatSync, readdirSync } from 'fs';
import { getMaps, getMapsOptimizers, getMapsScripts } from "wa-map-optimizer-vite";
import { defineConfig } from "vite";
import { getMaps, getMapsOptimizers, getMapsScripts, LogLevel, OptimizeOptions } from "wa-map-optimizer-vite";

const isDirectory = (path: string) => {
const stats = lstatSync(path)
return stats.isDirectory()
}

const maps = getMaps();

const isDirectory = (path: string) => {
const stats = lstatSync(path)
return stats.isDirectory()
}
let optimizerOptions: OptimizeOptions = {
logs: process.env.LOG_LEVEL && process.env.LOG_LEVEL in LogLevel ? LogLevel[process.env.LOG_LEVEL] : LogLevel.NORMAL,
};

if (process.env.TILESET_OPTIMIZATION && process.env.TILESET_OPTIMIZATION === "true") {
const qualityMin = process.env.TILESET_OPTIMIZATION_QUALITY_MIN ? parseInt(process.env.TILESET_OPTIMIZATION_QUALITY_MIN) : 0.9;
const qualityMax = process.env.TILESET_OPTIMIZATION_QUALITY_MAX ? parseInt(process.env.TILESET_OPTIMIZATION_QUALITY_MAX) : 1;

optimizerOptions.output = {
tileset: {
compress: {
quality: [qualityMin, qualityMax],
}
}
}
}

const getAllFromDirectory = async (directoryName: string, wantedExtension: string | null = null) => {
const fileList: { [p: string]: string } = {}
Expand All @@ -32,7 +50,7 @@ const getAllFromDirectory = async (directoryName: string, wantedExtension: strin
}
}
return fileList
}
}

export default defineConfig({
base: "./",
Expand All @@ -45,7 +63,7 @@ export default defineConfig({
},
},
},
plugins: [...getMapsOptimizers(maps)],
plugins: [...getMapsOptimizers(maps, optimizerOptions)],
server: {
host: "localhost",
headers: {
Expand Down

0 comments on commit d22eb45

Please sign in to comment.