npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-plugin-xhgis

v1.0.0

Published

Vite plugin for XH-GIS integration, similar to vite-plugin-cesium

Downloads

5

Readme

vite-plugin-xhgis

Vite plugin for XH-GIS integration, similar to vite-plugin-cesium.

Features

  • 🚀 Zero Configuration: Works out of the box, just like Cesium
  • 🔧 Development Server: Automatic asset serving in development mode
  • 📦 Production Build: Asset copying guidance for production builds
  • 🌍 Global Variables: Automatic XH_GIS_BASE_URL injection
  • 🎯 TypeScript Support: Full TypeScript support with type definitions

Installation

npm install vite-plugin-xhgis --save-dev
# or
yarn add vite-plugin-xhgis --dev
# or
pnpm add vite-plugin-xhgis --save-dev

Usage

Basic Usage

// vite.config.ts
import { defineConfig } from 'vite';
import { xhgis } from 'vite-plugin-xhgis';

export default defineConfig({
  plugins: [
    xhgis(), // Zero configuration!
  ],
});

With Options

// vite.config.ts
import { defineConfig } from 'vite';
import { xhgis } from 'vite-plugin-xhgis';

export default defineConfig({
  plugins: [
    xhgis({
      baseUrl: '/assets/xh-gis',  // Custom base URL
      devMode: true,              // Enable dev mode
      debug: true,                // Enable debug logging
    }),
  ],
});

In Your Application

// No need to call setResourceConfig manually!
// XH-GIS will automatically detect XH_GIS_BASE_URL
import { AbstractCore } from '@xh-gis/engine';

const core = new AbstractCore(container, {
  // Your options...
});

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseUrl | string | '/xh-gis/Assets' | Base URL for XH-GIS assets | | devMode | boolean | true | Enable development mode features | | xhgisPath | string | 'node_modules/@xh-gis/engine' | Path to XH-GIS package | | assetsDir | string | 'Assets' | Assets directory name | | debug | boolean | false | Enable debug logging |

How It Works

Development Mode

In development mode, the plugin:

  1. Serves Assets: Automatically serves XH-GIS assets from node_modules
  2. Injects Variables: Defines XH_GIS_BASE_URL globally
  3. Configures Server: Sets up Vite dev server to handle asset requests

Production Mode

In production mode, the plugin:

  1. Injects Variables: Defines XH_GIS_BASE_URL for the build
  2. Guides Asset Copying: Provides information about required asset copying
  3. Optimizes Bundle: Ensures proper asset references

Comparison with Cesium

This plugin follows the same patterns as vite-plugin-cesium:

| Feature | vite-plugin-cesium | vite-plugin-xhgis | |---------|-------------------|-------------------| | Zero Config | ✅ | ✅ | | Dev Server | ✅ | ✅ | | Global Variables | CESIUM_BASE_URL | XH_GIS_BASE_URL | | Asset Handling | Automatic | Automatic | | TypeScript | ✅ | ✅ |

Examples

React + Vite

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { xhgis } from 'vite-plugin-xhgis';

export default defineConfig({
  plugins: [
    react(),
    xhgis(),
  ],
});
// App.tsx
import React, { useEffect, useRef } from 'react';
import { AbstractCore } from '@xh-gis/engine';

function App() {
  const mapRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (mapRef.current) {
      // No configuration needed!
      const core = new AbstractCore(mapRef.current, {
        homeButton: false,
        sceneModePicker: false,
      });
    }
  }, []);

  return <div ref={mapRef} style={{ width: '100vw', height: '100vh' }} />;
}

export default App;

Vue + Vite

// vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { xhgis } from 'vite-plugin-xhgis';

export default defineConfig({
  plugins: [
    vue(),
    xhgis(),
  ],
});

Production Deployment

For production builds, ensure that XH-GIS assets are available at the configured baseUrl. You can:

  1. Copy assets manually to your public directory
  2. Use a CDN to serve XH-GIS assets
  3. Configure your web server to serve assets from the correct location

License

MIT