[maps][xl] - working with swc equals to minify
This commit is contained in:
parent
9ee4376abf
commit
6e8d5cb091
@ -26,9 +26,11 @@
|
||||
"dependencies": {
|
||||
"@githubocto/flat-ui": "^0.14.1",
|
||||
"@heroicons/react": "^2.0.17",
|
||||
"@planet/maps": "^8.1.0",
|
||||
"@tanstack/react-table": "^8.8.5",
|
||||
"flexsearch": "0.7.21",
|
||||
"next-mdx-remote": "^4.4.1",
|
||||
"ol": "^7.4.0",
|
||||
"papaparse": "^5.4.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@ -48,6 +50,7 @@
|
||||
"@storybook/react": "^7.0.7",
|
||||
"@storybook/react-vite": "^7.0.7",
|
||||
"@storybook/testing-library": "^0.0.14-next.2",
|
||||
"@swc/core": "^1.3.68",
|
||||
"@types/flexsearch": "^0.7.3",
|
||||
"@types/papaparse": "^5.3.7",
|
||||
"@types/react": "^18.0.28",
|
||||
@ -55,6 +58,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
||||
"@typescript-eslint/parser": "^5.57.1",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"@vitejs/plugin-react-swc": "^3.3.2",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"eslint": "^8.38.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
@ -67,7 +71,8 @@
|
||||
"tailwindcss": "^3.3.2",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.3.2",
|
||||
"vite-plugin-dts": "^2.3.0"
|
||||
"vite-plugin-dts": "^2.3.0",
|
||||
"vite-plugin-swc-only": "^0.1.18"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
84
packages/components/src/components/OpenLayers/Controls.jsx
Normal file
84
packages/components/src/components/OpenLayers/Controls.jsx
Normal file
@ -0,0 +1,84 @@
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
export const Controls = ({ children }) => {
|
||||
return <div>{children}</div>;
|
||||
};
|
||||
|
||||
import { FullScreen, Zoom } from 'ol/control';
|
||||
import { MapContext } from './Map';
|
||||
|
||||
export const FullScreenControl = () => {
|
||||
const { map } = useContext(MapContext);
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
let fullScreenControl = new FullScreen({
|
||||
className: 'ml-1 flex flex-col w-8 items-center mt-2',
|
||||
activeClassName:
|
||||
'w-full inline-flex justify-center items-center rounded-t-md bg-white px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10 text-sm',
|
||||
inactiveClassName:
|
||||
'inline-flex w-full justify-center items-center rounded-t-md bg-white px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10 text-sm',
|
||||
});
|
||||
let zoomControl = new Zoom({
|
||||
className: 'ml-1 flex flex-col w-8 items-center',
|
||||
zoomInClassName:
|
||||
'inline-flex w-full justify-center items-center bg-white px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10 text-sm',
|
||||
zoomOutClassName:
|
||||
'inline-flex w-full justify-center items-center rounded-b-md bg-white px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10 text-sm',
|
||||
});
|
||||
map.controls.push(fullScreenControl);
|
||||
map.controls.push(zoomControl);
|
||||
|
||||
return () => {
|
||||
map.controls.remove(zoomControl);
|
||||
map.controls.remove(fullScreenControl);
|
||||
};
|
||||
}, [map]);
|
||||
return null;
|
||||
};
|
||||
|
||||
//build a list of checkboxes in react
|
||||
|
||||
export const ListOfCheckboxes = ({ layers, shownLayers, setShownLayers }) => {
|
||||
//layers is an array of url and name
|
||||
function addLayer(layer) {
|
||||
setShownLayers([...shownLayers, layer.url]);
|
||||
}
|
||||
|
||||
function removeLayer(layer) {
|
||||
setShownLayers(shownLayers.filter((l) => l !== layer.url));
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3 className="mb-4 font-semibold text-gray-900 ">Layers</h3>
|
||||
<ul className="w-48 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg ">
|
||||
{layers.map((layer, index) => (
|
||||
<li
|
||||
key={index}
|
||||
className="w-full border-b border-gray-200 rounded-t-lg "
|
||||
>
|
||||
<div className="flex items-center pl-3">
|
||||
<input
|
||||
id={layer.name}
|
||||
type="checkbox"
|
||||
defaultChecked={shownLayers.includes(layer.url)}
|
||||
onClick={() =>
|
||||
shownLayers.includes(layer.url)
|
||||
? removeLayer(layer)
|
||||
: addLayer(layer)
|
||||
}
|
||||
value={true}
|
||||
className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2 "
|
||||
></input>
|
||||
<label
|
||||
htmlFor={layer.name}
|
||||
className="w-full py-3 ml-2 text-sm font-medium text-gray-90"
|
||||
>
|
||||
{layer.name}
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,29 @@
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
import HeatMap from 'ol/layer/Heatmap';
|
||||
import { MapContext } from './Map';
|
||||
const HeatMapLayer = ({ source, style, zIndex = 0 }) => {
|
||||
const { map } = useContext(MapContext);
|
||||
const [heatMapLayer, setHeatMapLayer] = useState(null);
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
let heatMapLayer = new HeatMap({
|
||||
source,
|
||||
style,
|
||||
blur: parseInt(5, 10),
|
||||
radius: parseInt(5, 10),
|
||||
});
|
||||
map.addLayer(heatMapLayer);
|
||||
setHeatMapLayer(heatMapLayer);
|
||||
heatMapLayer.setZIndex(zIndex);
|
||||
return () => {
|
||||
if (map) {
|
||||
map.removeLayer(heatMapLayer);
|
||||
}
|
||||
};
|
||||
}, [map]);
|
||||
useEffect(() => {
|
||||
heatMapLayer && heatMapLayer.setZIndex(zIndex);
|
||||
}, [zIndex]);
|
||||
return null;
|
||||
};
|
||||
export default HeatMapLayer;
|
||||
4
packages/components/src/components/OpenLayers/Layers.jsx
Normal file
4
packages/components/src/components/OpenLayers/Layers.jsx
Normal file
@ -0,0 +1,4 @@
|
||||
import React from 'react';
|
||||
export const Layers = ({ children }) => {
|
||||
return <div>{children}</div>;
|
||||
};
|
||||
50
packages/components/src/components/OpenLayers/Map.jsx
Normal file
50
packages/components/src/components/OpenLayers/Map.jsx
Normal file
@ -0,0 +1,50 @@
|
||||
import React, { useRef, useState, useEffect } from 'react';
|
||||
import * as ol from 'ol';
|
||||
|
||||
export const MapContext = new React.createContext();
|
||||
|
||||
const Map = ({ children, zoom, center, setSelected }) => {
|
||||
const mapRef = useRef();
|
||||
const [map, setMap] = useState(null);
|
||||
// on component mount
|
||||
useEffect(() => {
|
||||
let options = {
|
||||
view: new ol.View({ zoom, center }),
|
||||
layers: [],
|
||||
controls: [],
|
||||
overlays: [],
|
||||
};
|
||||
let mapObject = new ol.Map(options);
|
||||
mapObject.setTarget(mapRef.current);
|
||||
setMap(mapObject);
|
||||
return () => mapObject.setTarget(undefined);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
if (setSelected !== null) {
|
||||
let selected = null;
|
||||
map.on('pointermove', function (e) {
|
||||
map.forEachFeatureAtPixel(e.pixel, function (f) {
|
||||
selected = f;
|
||||
return true;
|
||||
});
|
||||
if (selected) {
|
||||
setSelected(selected);
|
||||
} else {
|
||||
setSelected(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [map]);
|
||||
return (
|
||||
<MapContext.Provider value={{ map }}>
|
||||
<div ref={mapRef} className="w-full h-[500px]">
|
||||
{children}
|
||||
</div>
|
||||
</MapContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default Map;
|
||||
136
packages/components/src/components/OpenLayers/OpenLayers.tsx
Normal file
136
packages/components/src/components/OpenLayers/OpenLayers.tsx
Normal file
@ -0,0 +1,136 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import Map from './Map';
|
||||
import { Layers } from './Layers';
|
||||
import { Fill, Icon, Style } from 'ol/style';
|
||||
import * as olSource from 'ol/source';
|
||||
import TileLayer from './TileLayer';
|
||||
import { fromLonLat } from 'ol/proj';
|
||||
import VectorLayer from './VectorLayer';
|
||||
import { Vector as VectorSource } from 'ol/source';
|
||||
import GeoJSON from 'ol/format/GeoJSON';
|
||||
import KML from 'ol/format/KML';
|
||||
import { colors } from './colors';
|
||||
import { FullScreenControl, Controls, ListOfCheckboxes } from './Controls';
|
||||
import HeatMapLayer from './HeatMapLayer';
|
||||
|
||||
function osm() {
|
||||
return new olSource.OSM();
|
||||
}
|
||||
|
||||
const formats = {
|
||||
geojson: new GeoJSON(),
|
||||
kml: new KML(),
|
||||
};
|
||||
|
||||
interface OpenLayersProps {
|
||||
layers: {
|
||||
url: string;
|
||||
name?: string;
|
||||
format?: string;
|
||||
heatmap?: boolean;
|
||||
}[];
|
||||
center?: [number, number];
|
||||
zoom?: number;
|
||||
popup?: (selected: any) => JSX.Element;
|
||||
}
|
||||
|
||||
export function OpenLayers({
|
||||
layers,
|
||||
center = [0, 0],
|
||||
zoom = 1,
|
||||
popup,
|
||||
}: OpenLayersProps) {
|
||||
const [shownLayers, setShownLayers] = useState(
|
||||
layers.map((layer) => layer.url)
|
||||
);
|
||||
const [selected, setSelected] = useState(null);
|
||||
const [style, setStyle] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const style = new Style({
|
||||
fill: new Fill({
|
||||
color: '#eeeeee',
|
||||
}),
|
||||
image: new Icon({
|
||||
anchor: [0.5, 46],
|
||||
anchorXUnits: 'fraction',
|
||||
anchorYUnits: 'pixels',
|
||||
width: 18,
|
||||
height: 28,
|
||||
src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Google_Maps_icon_%282020%29.svg/418px-Google_Maps_icon_%282020%29.svg.png?20200218211225',
|
||||
}),
|
||||
});
|
||||
setStyle(style);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<Map
|
||||
center={fromLonLat(center)}
|
||||
zoom={zoom}
|
||||
setSelected={popup ? setSelected : null}
|
||||
>
|
||||
<Layers>
|
||||
<TileLayer source={osm()} zIndex={0} />
|
||||
{layers.map((layer, index) =>
|
||||
!layer.heatmap ? (
|
||||
<VectorLayer
|
||||
key={index}
|
||||
zIndex={shownLayers.includes(layer.url) ? 1 : -1}
|
||||
source={
|
||||
new VectorSource({
|
||||
url: layer.url,
|
||||
format: layer.format
|
||||
? formats[layer.format]
|
||||
: new GeoJSON(),
|
||||
})
|
||||
}
|
||||
style={function (feature) {
|
||||
const id = feature.getId();
|
||||
const color = feature.get('COLOR') || colors[id % 1302].hex;
|
||||
style.getFill().setColor(color);
|
||||
return style;
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<HeatMapLayer
|
||||
key={index}
|
||||
zIndex={shownLayers.includes(layer.url) ? 1 : -1}
|
||||
source={
|
||||
new VectorSource({
|
||||
url: layer.url,
|
||||
format: layer.format
|
||||
? formats[layer.format]
|
||||
: new GeoJSON(),
|
||||
})
|
||||
}
|
||||
style={function (feature) {
|
||||
const color =
|
||||
feature.get('COLOR') || colors[feature.ol_uid % 1302].hex;
|
||||
style.getFill().setColor(color);
|
||||
return style;
|
||||
}}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</Layers>
|
||||
{/* add a floating pane that will output the ListOfCheckboxes component using tailwind*/}
|
||||
<div className="absolute bottom-0 right-0 m-4 p-4 z-50 bg-white rounded-lg shadow-xl">
|
||||
<ListOfCheckboxes
|
||||
layers={layers}
|
||||
shownLayers={shownLayers}
|
||||
setShownLayers={setShownLayers}
|
||||
/>
|
||||
</div>
|
||||
{popup && selected && (
|
||||
<div className="absolute bottom-0 left-0 m-4 p-4 z-50 bg-white rounded-lg shadow-xl">
|
||||
{popup(selected)}
|
||||
</div>
|
||||
)}
|
||||
<Controls>
|
||||
<FullScreenControl />
|
||||
</Controls>
|
||||
</Map>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
23
packages/components/src/components/OpenLayers/TileLayer.jsx
Normal file
23
packages/components/src/components/OpenLayers/TileLayer.jsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { useContext, useEffect } from 'react';
|
||||
import OLTileLayer from 'ol/layer/Tile';
|
||||
import { MapContext } from './Map';
|
||||
const TileLayer = ({ source, zIndex = 0 }) => {
|
||||
const { map } = useContext(MapContext);
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
|
||||
let tileLayer = new OLTileLayer({
|
||||
source,
|
||||
zIndex,
|
||||
});
|
||||
map.addLayer(tileLayer);
|
||||
tileLayer.setZIndex(zIndex);
|
||||
return () => {
|
||||
if (map) {
|
||||
map.removeLayer(tileLayer);
|
||||
}
|
||||
};
|
||||
}, [map]);
|
||||
return null;
|
||||
};
|
||||
export default TileLayer;
|
||||
@ -0,0 +1,33 @@
|
||||
import { useContext, useEffect, useState } from 'react';
|
||||
import OLVectorLayer from 'ol/layer/Vector';
|
||||
import { MapContext } from './Map';
|
||||
const VectorLayer = ({ source, style, zIndex = 0 }) => {
|
||||
const { map } = useContext(MapContext);
|
||||
const [vectorLayer, setVectorLayer] = useState(null);
|
||||
useEffect(() => {
|
||||
if (!map) return;
|
||||
let vectorLayer = new OLVectorLayer({
|
||||
source,
|
||||
style,
|
||||
});
|
||||
const vectorSource = vectorLayer.getSource();
|
||||
vectorSource.on('featuresloadend', function () {
|
||||
vectorSource.getFeatures().forEach((feature, index) => {
|
||||
feature.setId(index);
|
||||
});
|
||||
});
|
||||
map.addLayer(vectorLayer);
|
||||
setVectorLayer(vectorLayer);
|
||||
vectorLayer.setZIndex(zIndex);
|
||||
return () => {
|
||||
if (map) {
|
||||
map.removeLayer(vectorLayer);
|
||||
}
|
||||
};
|
||||
}, [map]);
|
||||
useEffect(() => {
|
||||
vectorLayer && vectorLayer.setZIndex(zIndex);
|
||||
}, [zIndex]);
|
||||
return null;
|
||||
};
|
||||
export default VectorLayer;
|
||||
5210
packages/components/src/components/OpenLayers/colors.js
Normal file
5210
packages/components/src/components/OpenLayers/colors.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
export * from "./components/Table";
|
||||
export * from "./components/Catalog";
|
||||
export * from "./components/LineChart";
|
||||
export * from "./components/Vega";
|
||||
export * from "./components/VegaLite";
|
||||
export * from "./components/FlatUiTable";
|
||||
export * from './components/Table';
|
||||
export * from './components/Catalog';
|
||||
export * from './components/LineChart';
|
||||
export * from './components/Vega';
|
||||
export * from './components/VegaLite';
|
||||
export * from './components/FlatUiTable';
|
||||
export * from './components/OpenLayers/OpenLayers';
|
||||
|
||||
136
packages/components/stories/OpenLayers.stories.tsx
Normal file
136
packages/components/stories/OpenLayers.stories.tsx
Normal file
@ -0,0 +1,136 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
import React from 'react';
|
||||
import { OpenLayers } from '../src/components/OpenLayers/OpenLayers';
|
||||
|
||||
const meta: Meta = {
|
||||
title: 'Components/OpenLayers',
|
||||
component: OpenLayers,
|
||||
argTypes: {
|
||||
layers: {
|
||||
description: 'Layers to be added to the map',
|
||||
control: {
|
||||
type: 'array',
|
||||
},
|
||||
},
|
||||
center: {
|
||||
description: 'Center of the map',
|
||||
defaultValue: [0, 0],
|
||||
control: {
|
||||
type: 'array',
|
||||
},
|
||||
},
|
||||
zoom: {
|
||||
description: 'Zoom level of the map',
|
||||
defaultValue: 1,
|
||||
control: {
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<any>;
|
||||
|
||||
export const Secondary: Story = {
|
||||
name: 'Map with OpenLayers',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://openlayers.org/data/vector/ecoregions.json',
|
||||
name: 'Ecoregions',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const Primary: Story = {
|
||||
name: 'Map with OpenLayers 2',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_geography_marine_polys.geojson',
|
||||
name: 'Marine regions',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const MapWithPopover: Story = {
|
||||
name: 'Map with popup',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://openlayers.org/data/vector/ecoregions.json',
|
||||
name: 'Ecoregions',
|
||||
},
|
||||
],
|
||||
popup: (feature: any) => {
|
||||
return (
|
||||
<div className="flex flex-col gap-y-1" style={{ color: 'red' }}>
|
||||
<span className="font-bold">Biome name</span>
|
||||
<span className="text-sm">{feature.values_.BIOME_NAME}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const Third: Story = {
|
||||
name: 'Map with two layers',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_geography_marine_polys.geojson',
|
||||
name: 'Marine regions',
|
||||
},
|
||||
{
|
||||
url: 'https://openlayers.org/data/vector/ecoregions.json',
|
||||
name: 'Ecoregions',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomCenter: Story = {
|
||||
name: 'Map with custom center and zoom',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://openlayers.org/data/vector/ecoregions.json',
|
||||
name: 'Ecoregions',
|
||||
},
|
||||
],
|
||||
center: [-15, 20],
|
||||
zoom: 4,
|
||||
},
|
||||
};
|
||||
|
||||
export const PointsOnMap: Story = {
|
||||
name: 'Map with points on',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://opendata.arcgis.com/datasets/9c58741995174fbcb017cf46c8a42f4b_25.geojson',
|
||||
name: 'E-Scooter Parking Bays',
|
||||
},
|
||||
],
|
||||
center: [-1.055429957881787, 53.963900188025301],
|
||||
zoom: 12,
|
||||
},
|
||||
};
|
||||
|
||||
export const KMLFile: Story = {
|
||||
name: 'Map with KML File',
|
||||
args: {
|
||||
layers: [
|
||||
{
|
||||
url: 'https://openlayers.org/en/latest/examples/data/kml/2012_Earthquakes_Mag5.kml',
|
||||
name: '2012 Earthquakes M5+',
|
||||
format: 'kml',
|
||||
heatmap: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
||||
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx,.stories.tsx}'],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
|
||||
@ -1,29 +1,15 @@
|
||||
import react from '@vitejs/plugin-react'
|
||||
import path from 'node:path'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import dts from 'vite-plugin-dts'
|
||||
import tailwindcss from 'tailwindcss'
|
||||
import { UserConfigExport } from 'vite'
|
||||
import replace from "rollup-plugin-re"
|
||||
import react from '@vitejs/plugin-react-swc';
|
||||
import path from 'node:path';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import dts from 'vite-plugin-dts';
|
||||
import tailwindcss from 'tailwindcss';
|
||||
import { UserConfigExport } from 'vite';
|
||||
import replace from 'rollup-plugin-re';
|
||||
|
||||
const app = async (): Promise<UserConfigExport> => {
|
||||
return defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
replace({
|
||||
patterns: [
|
||||
{
|
||||
match: /js-sha256/,
|
||||
test: `eval("require('crypto')")`,
|
||||
replace: `require('crypto')`,
|
||||
},
|
||||
{
|
||||
match: /js-sha256/,
|
||||
test: `eval("require('buffer').Buffer")`,
|
||||
replace: `require('buffer').Buffer`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
dts({
|
||||
insertTypesEntry: true,
|
||||
}),
|
||||
@ -34,6 +20,7 @@ const app = async (): Promise<UserConfigExport> => {
|
||||
},
|
||||
},
|
||||
build: {
|
||||
target: 'es2020',
|
||||
lib: {
|
||||
entry: path.resolve(__dirname, 'src/index.ts'),
|
||||
name: 'components',
|
||||
@ -41,10 +28,25 @@ const app = async (): Promise<UserConfigExport> => {
|
||||
fileName: (format) => `components.${format}.js`,
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ['react', 'react-dom', 'tailwindcss', 'vega-lite', 'vega', 'react-vega'],
|
||||
external: [
|
||||
'react',
|
||||
'ol-mapbox-style',
|
||||
'react-dom',
|
||||
'tailwindcss',
|
||||
'vega-lite',
|
||||
'vega',
|
||||
'react-vega',
|
||||
'ol',
|
||||
'ol/dom.js',
|
||||
],
|
||||
output: {
|
||||
manualChunks: undefined,
|
||||
globals: {
|
||||
react: 'React',
|
||||
ol: 'ol',
|
||||
'ol-mapbox-style': 'ol-mapbox-style',
|
||||
'ol/dom.js': 'ol/dom.js',
|
||||
'react-vega': 'react-vega',
|
||||
'react-dom': 'ReactDOM',
|
||||
tailwindcss: 'tailwindcss',
|
||||
},
|
||||
@ -55,7 +57,7 @@ const app = async (): Promise<UserConfigExport> => {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
},
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
// https://vitejs.dev/config/
|
||||
export default app
|
||||
export default app;
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
// vite.config.ts
|
||||
import react from "file:///home/urutu-branco/Projetos/portaljs/node_modules/@vitejs/plugin-react-swc/index.mjs";
|
||||
import path from "node:path";
|
||||
import { defineConfig } from "file:///home/urutu-branco/Projetos/portaljs/node_modules/vitest/dist/config.js";
|
||||
import dts from "file:///home/urutu-branco/Projetos/portaljs/node_modules/vite-plugin-dts/dist/index.mjs";
|
||||
import tailwindcss from "file:///home/urutu-branco/Projetos/portaljs/node_modules/tailwindcss/lib/index.js";
|
||||
var __vite_injected_original_dirname = "/home/urutu-branco/Projetos/portaljs/packages/components";
|
||||
var app = async () => {
|
||||
return defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
dts({
|
||||
insertTypesEntry: true
|
||||
})
|
||||
],
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [tailwindcss]
|
||||
}
|
||||
},
|
||||
build: {
|
||||
target: "es2020",
|
||||
lib: {
|
||||
entry: path.resolve(__vite_injected_original_dirname, "src/index.ts"),
|
||||
name: "components",
|
||||
formats: ["es", "umd"],
|
||||
fileName: (format) => `components.${format}.js`
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [
|
||||
"react",
|
||||
"ol-mapbox-style",
|
||||
"react-dom",
|
||||
"tailwindcss",
|
||||
"vega-lite",
|
||||
"vega",
|
||||
"react-vega",
|
||||
"ol",
|
||||
"ol/dom.js"
|
||||
],
|
||||
output: {
|
||||
manualChunks: void 0,
|
||||
globals: {
|
||||
react: "React",
|
||||
ol: "ol",
|
||||
"ol/dom.js": "ol/dom.js",
|
||||
"react-vega": "react-vega",
|
||||
"react-dom": "ReactDOM",
|
||||
tailwindcss: "tailwindcss"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: "jsdom"
|
||||
}
|
||||
});
|
||||
};
|
||||
var vite_config_default = app;
|
||||
export {
|
||||
vite_config_default as default
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS91cnV0dS1icmFuY28vUHJvamV0b3MvcG9ydGFsanMvcGFja2FnZXMvY29tcG9uZW50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL2hvbWUvdXJ1dHUtYnJhbmNvL1Byb2pldG9zL3BvcnRhbGpzL3BhY2thZ2VzL2NvbXBvbmVudHMvdml0ZS5jb25maWcudHNcIjtjb25zdCBf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ICBmb3JtYXRzOiBbJ2VzJywgJ3VtZCddLFxuICAgICAgICBmaWxlTmFtZTogKGZvcm1hdCkgPT4gYGNvbXBvbmVudHMuJHtmb3JtYXR9LmpzYCxcbiAgICAgIH0sXG4gICAgICByb2xsdXBPcHRpb25zOiB7XG4gICAgICAgIGV4dGVybmFsOiBbXG4gICAgICAgICAgJ3JlYWN0JyxcbiAgICAgICAgICAnb2wtbWFwYm94LXN0eWxlJyxcbiAgICAgICAgICAncmVhY3QtZG9tJyxcbiAgICAgICAgICAndGFpbHdpbmRjc3MnLFxuICAgICAgICAgICd2ZWdhLWxpdGUnLFxuICAgICAgICAgICd2ZWdhJyxcbiAgICAgICAgICAncmVhY3QtdmVnYScsXG4gICAgICAgICAgJ29sJyxcbiAgICAgICAgICAnb2wvZG9tLmpzJyxcbiAgICAgICAgXSxcbiAgICAgICAgb3V0cHV0OiB7XG4gICAgICAgICAgbWFudWFsQ2h1bmtzOiB1bmRlZmluZWQsXG4gICAgICAgICAgZ2xvYmFsczoge1xuICAgICAgICAgICAgcmVhY3Q6ICdSZWFjdCcsXG4gICAgICAgICAgICBvbDogJ29sJyxcbiAgICAgICAgICAgICdvbC9kb20uanMnOiAnb2wvZG9tLmpzJyxcbiAgICAgICAgICAgICdyZWFjdC12ZWdhJzogJ3JlYWN0LXZlZ2EnLFxuICAgICAgICAgICAgJ3JlYWN0LWRvbSc6ICdSZWFjdERPTScsXG4gICAgICAgICAgICB0YWlsd2luZGNzczogJ3RhaWx3aW5kY3NzJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICB9LFxuICAgIHRlc3Q6IHtcbiAgICAgIGdsb2JhbHM6IHRydWUsXG4gICAgICBlbnZpcm9ubWVudDogJ2pzZG9tJyxcbiAgICB9LFxuICB9KTtcbn07XG4vLyBodHRwczovL3ZpdGVqcy5kZXYvY29uZmlnL1xuZXhwb3J0IGRlZmF1bHQgYXBwO1xuIl0sCiAgIm1hcHBpbmdzIjogIj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