fix docz production build

This commit is contained in:
Stephan Meijer
2020-04-13 13:27:30 +02:00
parent 6645d63c82
commit c3a2378ecb
15 changed files with 2622 additions and 2180 deletions

View File

@@ -1,18 +0,0 @@
html, body {
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: border-box;
}
:global(.leaflet-control-geosearch.bar) {
position: absolute !important;
left: 50px;
right: 515px;
}

View File

@@ -1,9 +1,4 @@
.root {
.map {
width: 100%;
height: 300px;
}
.map {
width: 100%;
height: 100%;
}

View File

@@ -1,11 +1,12 @@
import React, { ReactElement, useRef, useEffect } from 'react';
import 'leaflet/dist/leaflet.css';
import { Map, TileLayer } from 'react-leaflet';
import styles from './Leaflet.module.css';
import '../../assets/css/leaflet.css';
import useConfigureLeaflet from '../hooks/useConfigureLeaflet';
import * as providers from '../../src/providers';
import GeoSearchControl from '../../src/leafletControl';
import styles from './Leaflet.module.css';
import { MapProps } from './Map';
@@ -55,9 +56,11 @@ function Leaflet(props: MapProps): ReactElement {
};
}, [ref.current, control.current, provider]);
// I'm not sure what's causing it, but the className from the outer
// div is being removed. Hence the useless wrapper
return (
<div className={styles.root}>
<Map ref={ref} viewport={viewport} className={styles.map}>
<div>
<Map ref={ref} viewport={viewport} id="map" className={styles.map}>
<TileLayer url="//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
</Map>
</div>

View File

@@ -1,20 +1,17 @@
import React, { ReactElement, lazy, Suspense } from 'react';
import 'leaflet/dist/leaflet.css';
const Leaflet = lazy(() => import('./Leaflet'));
const Loader = () => <div>loading...</div>;
import React, { ReactElement } from 'react';
import Leaflet from './Leaflet';
export interface MapProps {
provider: 'OpenStreetMap' | 'Google' | 'Bing';
provider?: 'OpenStreetMap' | 'Google' | 'Bing';
providerOptions: any;
}
function Map(props: MapProps): ReactElement {
return (
<Suspense fallback={<Loader />}>
<Leaflet provider={props.provider} />
</Suspense>
);
if (typeof window === 'undefined') {
return <div>loading...</div>;
}
return <Leaflet provider={props.provider} />;
}
export default Map;

View File

@@ -1,6 +1,4 @@
import L from 'leaflet';
import isDomAvailable from '../lib/isDomAvailable';
import { Viewport } from 'react-leaflet';
const viewport: Viewport = {
@@ -13,7 +11,7 @@ export interface LeafletConfig {
}
const useConfigureLeaflet = (): LeafletConfig => {
if (!isDomAvailable()) return;
if (!window) return;
// To get around an issue with the default icon not being set up right between using React
// and importing the leaflet library, we need to reset the image imports

View File

@@ -22,7 +22,7 @@ Although this project is named `leaflet-geosearch`, this library is also usable
## Installation
```bash
npm install --save leaflet-geosearch
npm install leaflet-geosearch
```
## Providers

View File

@@ -6,7 +6,7 @@ export default {
},
src: 'docs',
dest: '.docz/dist',
public: 'assets',
public: 'docs/assets',
ignore: ['CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'LICENSE.md'],
menu: [
{ name: 'Introduction' },

View File

@@ -1 +1 @@
import './static/assets/css/docs.css';
import './static/docs/assets/css/global.css';

View File

@@ -1,3 +1,14 @@
require('dotenv').config({
path: '.env',
});
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-react-leaflet',
options: {
linkStyles: true,
},
},
],
};

View File

@@ -1,16 +0,0 @@
exports.onCreateWebpackConfig = ({ stage, rules, loaders, actions }) => {
switch (stage) {
case 'build-html':
actions.setWebpackConfig({
module: {
rules: [
{
test: /react-leaflet|leaflet/,
use: [loaders.null()],
},
],
},
});
break;
}
};

View File

@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const tsConfig = require('./tsconfig.json');
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
@@ -12,4 +15,13 @@ module.exports = {
},
automock: false,
setupFiles: ['./jest.setup.js'],
globals: {
'ts-jest': {
tsConfig: {
...tsConfig.compilerOptions,
noEmit: false,
outDir: '.tsCache',
},
},
},
};

4674
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -24,9 +24,6 @@
"directories": {
"example": "example"
},
"resolutions": {
"docz/**/webpack": "4.28.4"
},
"keywords": [
"geolocation",
"geocoding",

View File

@@ -1,17 +1,18 @@
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "./dist/tsc.js",
"sourceMap": true,
"allowJs": true,
"target":"es2015",
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"noUnusedLocals": true,
"jsx": "preserve",
"target": "ES5",
"outDir": ".tsout"
"noEmit": true,
"jsx": "react",
"inlineSourceMap": true,
"allowJs": true,
"pretty": true,
"strict": true,
"skipLibCheck": false
},
"include": [
"src/**/*",