Replace snowpack with vite (#334)

* Replace snowpack with vite

* changelog

* Drop old snowpack setting

* Fix
This commit is contained in:
Will Hunt 2022-05-06 09:57:18 +01:00 committed by GitHub
parent f3b6b939ce
commit f5eefaa381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 403 additions and 2018 deletions

1
changelog.d/334.misc Normal file
View File

@ -0,0 +1 @@
Replace 'snowpack' with 'vite' for building the widget web components.

View File

@ -14,12 +14,12 @@
"node": ">=14"
},
"scripts": {
"build:web": "snowpack build",
"build:web": "vite build",
"build:app": "tsc --project tsconfig.json",
"build:app:rs": "napi build --dts ../src/libRs.d.ts --release ./lib",
"build:app:fix-defs": "ts-node scripts/definitions-fixer.ts src/libRs.d.ts",
"build:docs": "ts-node scripts/build-metrics-docs.ts > docs/metrics.md && mdbook build",
"dev:web": "snowpack dev",
"dev:web": "vite dev",
"build": "scripts/build-app.sh",
"prepare": "yarn build",
"start": "node --require source-map-support/register lib/App/BridgeApp.js",
@ -35,12 +35,10 @@
},
"dependencies": {
"@alloc/quick-lru": "^5.2.0",
"@codemirror/lang-javascript": "^0.19.7",
"@octokit/auth-app": "^3.3.0",
"@octokit/auth-token": "^2.4.5",
"@octokit/rest": "^18.10.0",
"@octokit/webhooks": "^9.1.2",
"@uiw/react-codemirror": "^4.5.3",
"ajv": "^8.11.0",
"axios": "^0.24.0",
"cors": "^2.8.5",
@ -66,11 +64,10 @@
"yaml": "^1.10.2"
},
"devDependencies": {
"@codemirror/lang-javascript": "^0.19.7",
"@fontsource/open-sans": "^4.2.2",
"@napi-rs/cli": "^2.2.0",
"@prefresh/snowpack": "^3.1.2",
"@snowpack/plugin-sass": "^1.4.0",
"@snowpack/plugin-typescript": "^1.2.1",
"@preact/preset-vite": "^2.2.0",
"@types/ajv": "^1.0.0",
"@types/chai": "^4.2.22",
"@types/cors": "^2.8.12",
@ -86,6 +83,7 @@
"@types/uuid": "^8.3.3",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@uiw/react-codemirror": "^4.5.3",
"chai": "^4.3.4",
"eslint": "^8.3.0",
"eslint-config-preact": "^1.3.0",
@ -93,8 +91,9 @@
"mini.css": "^3.0.1",
"mocha": "^8.2.1",
"preact": "^10.5.15",
"snowpack": "^3.8.8",
"sass": "^1.51.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
"typescript": "^4.5.2",
"vite": "^2.9.8"
}
}

View File

@ -1,25 +0,0 @@
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount: {
"web/": '/'
},
plugins: [
'@prefresh/snowpack',
'@snowpack/plugin-sass',
['@snowpack/plugin-typescript', '--project tsconfig.web.json'],
],
packageOptions: {
installTypes: true,
polyfillNode: true,
},
buildOptions: {
out: 'public',
},
alias: {
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime",
}
};

View File

@ -7,8 +7,6 @@
"jsx": "preserve",
"jsxFactory": "h",
"baseUrl": "./",
/* paths - If you configure Snowpack import aliases, add them here. */
"paths": {},
/* noEmit - Snowpack builds (emits) files, not tsc. */
"noEmit": true,
/* Additional Options */

13
vite.config.js Normal file
View File

@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [preact()],
root: 'web',
base: '/widgetapi/v1/static/',
build: {
outDir: '../public',
emptyOutDir: true,
},
})

View File

@ -7,6 +7,9 @@ import { ConnectionCard } from "./ConnectionCard";
import { GenericWebhookConfig } from "./roomConfig/GenericWebhookConfig";
import { GitlabRepoConfig } from "./roomConfig/GitlabRepoConfig";
import GitLabIcon from "../icons/gitlab.png";
import WebhookIcon from "../icons/webhook.png";
interface IProps {
widgetApi: WidgetApi,
@ -29,14 +32,14 @@ export default function RoomConfigView(props: IProps) {
content = <>
<section>
<h2> Integrations </h2>
{props.supportedServices["gitlab"] && <ConnectionCard
imageSrc="./icons/gitlab.png"
{props.supportedServices.gitlab && <ConnectionCard
imageSrc={GitLabIcon}
serviceName="GitLab"
description="Connect the room to a GitLab project"
onClick={() => setActiveConnectionType("gitlab")}
/>}
{props.supportedServices["generic"] && <ConnectionCard
imageSrc="./icons/webhook.png"
{props.supportedServices.generic && <ConnectionCard
imageSrc={WebhookIcon}
serviceName="Generic Webhook"
description="Create a webhook which can be used to connect any service to Matrix"
onClick={() => setActiveConnectionType("generic")}

View File

@ -14,8 +14,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 400;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-Regular.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-Regular.woff?v=3.18") format("woff");
src: url("./Inter/Inter-Regular.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-Regular.woff?v=3.18") format("woff");
}
@font-face {
font-family: 'Inter';
@ -23,8 +23,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 400;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-Italic.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-Italic.woff?v=3.18") format("woff");
src: url("./Inter/Inter-Italic.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-Italic.woff?v=3.18") format("woff");
}
@font-face {
@ -33,8 +33,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 500;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-Medium.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-Medium.woff?v=3.18") format("woff");
src: url("./Inter/Inter-Medium.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-Medium.woff?v=3.18") format("woff");
}
@font-face {
font-family: 'Inter';
@ -42,8 +42,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 500;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-MediumItalic.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-MediumItalic.woff?v=3.18") format("woff");
src: url("./Inter/Inter-MediumItalic.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-MediumItalic.woff?v=3.18") format("woff");
}
@font-face {
@ -52,8 +52,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 600;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-SemiBold.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-SemiBold.woff?v=3.18") format("woff");
src: url("./Inter/Inter-SemiBold.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-SemiBold.woff?v=3.18") format("woff");
}
@font-face {
font-family: 'Inter';
@ -61,8 +61,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 600;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-SemiBoldItalic.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-SemiBoldItalic.woff?v=3.18") format("woff");
src: url("./Inter/Inter-SemiBoldItalic.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-SemiBoldItalic.woff?v=3.18") format("woff");
}
@font-face {
@ -71,8 +71,8 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 700;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-Bold.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-Bold.woff?v=3.18") format("woff");
src: url("./Inter/Inter-Bold.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-Bold.woff?v=3.18") format("woff");
}
@font-face {
font-family: 'Inter';
@ -80,6 +80,6 @@ $inter-unicode-range: U+0000-20e2,U+20e4-23ce,U+23d0-24c1,U+24c3-259f,U+25c2-266
font-weight: 700;
font-display: swap;
unicode-range: $inter-unicode-range;
src: url("./fonts/Inter/Inter-BoldItalic.woff2?v=3.18") format("woff2"),
url("./fonts/Inter/Inter-BoldItalic.woff?v=3.18") format("woff");
src: url("./Inter/Inter-BoldItalic.woff2?v=3.18") format("woff2"),
url("./Inter/Inter-BoldItalic.woff?v=3.18") format("woff");
}

View File

@ -8,6 +8,6 @@
<body>
<main id="root"></main>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script type="module" src="index.js"></script>
<script type="module" src="/index.tsx"></script>
</body>
</html>

2318
yarn.lock

File diff suppressed because it is too large Load Diff