vite configuration

This commit is contained in:
Brandon Liu
2022-05-04 22:34:27 +08:00
parent dacf779989
commit ade6b7508e
5 changed files with 6 additions and 4 deletions

View File

@@ -19,7 +19,8 @@ jobs:
with: with:
node-version: 16.x node-version: 16.x
- run: cd js && npm install && npm run build - run: cd js && npm install && npm run build
- run: cd app && npm install && npm run build - run: echo "VITE_GIT_SHA=$(git rev-parse --short HEAD)" >> app/.env
- run: cd app && npm install && ./node_modules/.bin/tsc && ./node_modules/.bin/vite build --base=/PMTiles/
- name: build_app - name: build_app
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }} if: ${{ github.ref == 'refs/heads/master' }}

1
app/.gitignore vendored
View File

@@ -22,3 +22,4 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
.env

View File

@@ -4,7 +4,6 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {

View File

@@ -10,6 +10,8 @@ const Header = styled("div", {
height: "$4", height: "$4",
}); });
const GIT_SHA = import.meta.env.VITE_GIT_SHA.substr(0,8)
function App() { function App() {
globalStyles(); globalStyles();
@@ -27,7 +29,7 @@ function App() {
return ( return (
<div> <div>
<Header>pmtiles viewer | github | toggle</Header> <Header>pmtiles viewer | github | toggle | {GIT_SHA}</Header>
{file ? <MaplibreMap file={file} /> : <Start setFile={setFile} />} {file ? <MaplibreMap file={file} /> : <Start setFile={setFile} />}
</div> </div>
); );

View File

@@ -2,6 +2,5 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
export default defineConfig({ export default defineConfig({
base:'/PMTiles/',
plugins: [react()] plugins: [react()]
}) })