Skip to content

Commit

Permalink
Build example differently
Browse files Browse the repository at this point in the history
  • Loading branch information
w8r committed Mar 5, 2024
1 parent d02bc2a commit c7fc17f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 10 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ jobs:
- name: Build lib
run: |
npm run build
mkdir docs
cp -R dist example index.html docs/
mkdir docs/src && cp src/main.mjs docs/src/
npm run docs
# Demo
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: 'docs' # The folder the action should deploy.
folder: 'dist/docs' # The folder the action should deploy.
5 changes: 5 additions & 0 deletions docs/assets/index-CzJhJ08r.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/assets/index-DE0_74oy.css

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html>
<head>
<title>L.Path.Drag</title>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap" rel="stylesheet">
<!--<script src="leaflet-master/leaflet-src.js"></script>-->
<!-- <script src="../dist/Leaflet.Path.Drag.min.js"></script> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.draw.css">
<script type="module" crossorigin src="./assets/index-CzJhJ08r.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DE0_74oy.css">
</head>
<body>
<div id="map"></div>
<div id="controls">
<div class="wrapper">
<h2>L.Path.Drag</h2>
<a class="github-button" href="https://github.com/w8r/Leaflet.Path.Drag" data-count-href="/w8r/Leaflet.Path.Drag/stargazers" data-count-api="/repos/w8r/Leaflet.Path.Drag#stargazers_count">Star</a>
<a class="github-button" href="https://github.com/w8r/Leaflet.Path.Drag" data-count-href="/w8r/Leaflet.Path.Drag/network" data-count-api="/repos/w8r/Leaflet.Path.Drag#forks_count">Fork</a>
<p>
Drag features around to see it in action<br>
<em>Red polygon has ~13 000 points</em><br><br>
<a href="//github.com/w8r/Leaflet.Path.Drag/">Documentation</a>
</p>

</div>
<div>
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions example/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vite';

export default defineConfig({
base: './',
build: {
outDir: 'dist/docs',
},
});
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
],
"scripts": {
"test": "browserify --transform [ babelify --presets [ es2015 ] ] ./test/*.test.js | tape-run --render='tap-spec' | tap-status",
"start": "vite",
"start": "vite -c example/vite.config.ts",
"lint": "eslint ./src/*.mjs",
"build-js": "vite build",
"build": "npm run lint && npm run build-js",
"docs": "vite build -c example/vite.config.ts",
"build": "npm run lint && vite build",
"release": "git push origin master && git checkout gh-pages && git merge master && git push origin gh-pages && git checkout master && npm publish"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/main.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as L from 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/+esm'; // L.Browser.retina = true;
import * as L from 'leaflet'; // L.Browser.retina = true;
// use UMD build for the plugin
import '../dist/index.js';
import '../dist/';

////////////////////////////////////////////////////////////////////////////////
const map = (window.map = new L.Map('map', {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const extensions = {
export default defineConfig({
build: {
lib: {
formats: ['es', 'umd', 'cjs'],
entry: 'src/index.mjs',
formats: ['es', 'umd', 'cjs'],
name: require('./package.json').name,
fileName: (format) => `index.${extensions[format]}`,
},
Expand Down

0 comments on commit c7fc17f

Please sign in to comment.