Skip to content

Commit

Permalink
Make use of Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed Apr 17, 2024
1 parent 5e9d189 commit df1c451
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true
- name: Make dist directory
run: |
mkdir dist
rsync --relative --recursive index.html meshmon.js meshmon.css assets/ protobufs/meshtastic/*.proto dist/
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mqtt/5.5.2/mqtt.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/protobufjs/7.2.6/protobuf.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js"></script>
<script type="text/javascript" src="meshmon.js"></script>
<script type="module" src="meshmon.js"></script>
</head>
<body>
<table class="table-main">
Expand Down
7 changes: 3 additions & 4 deletions meshmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,9 @@ function onFilterEnter() {
filterInput.classList.remove('filter-ok');
filterInput.classList.remove('filter-error');
} else {
const newFilterExpr = eval?.(`(h) => {
with (h) {
return ${filterInput.value};
}
const newFilterExpr = new Function('h', `{
const { ${fields.join(', ')} } = h;
return ${filterInput.value};
}`);
try {
newFilterExpr(dummyHeader);
Expand Down
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "meshmon",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.2.0",
"vite-plugin-static-copy": "^1.0.2"
}
}
15 changes: 15 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default {
base: '/meshmon/',
plugins: [
viteStaticCopy({
targets: [
{
src: 'protobufs/meshtastic/*.proto',
dest: 'protobufs/meshtastic/'
}
]
})
]
}

0 comments on commit df1c451

Please sign in to comment.