[Embeds] Create vite project and add to build pipeline (#3448)
* add bskyembed vite app * create build script (temp until embedr is ready)zio/stable
parent
24bd3d6986
commit
ad97d4350c
|
@ -32,7 +32,8 @@ RUN \. "$NVM_DIR/nvm.sh" && \
|
||||||
npm install --global yarn && \
|
npm install --global yarn && \
|
||||||
yarn && \
|
yarn && \
|
||||||
yarn intl:build && \
|
yarn intl:build && \
|
||||||
yarn build-web
|
yarn build-web && \
|
||||||
|
yarn build-embed
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
RUN find ./bskyweb/static && find ./web-build/static
|
RUN find ./bskyweb/static && find ./web-build/static
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -12,6 +12,7 @@ help: ## Print info about all commands
|
||||||
build-web: ## Compile web bundle, copy to bskyweb directory
|
build-web: ## Compile web bundle, copy to bskyweb directory
|
||||||
yarn intl:build
|
yarn intl:build
|
||||||
yarn build-web
|
yarn build-web
|
||||||
|
yarn build-embed
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: ## Run all tests
|
test: ## Run all tests
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": ["@typescript-eslint", "simple-import-sort"],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"preact",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"simple-import-sort/imports": "warn",
|
||||||
|
"simple-import-sort/exports": "warn"
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"project": "./tsconfig.json"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Vite App</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "bskyembed",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx src"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"preact": "^10.4.8"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@prefresh/vite": "^1.2.1",
|
||||||
|
"eslint": "^8.19.0",
|
||||||
|
"eslint-config-preact": "^1.3.0",
|
||||||
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
||||||
|
"typescript": "^4.0.5",
|
||||||
|
"vite": "^1.0.0-rc.13",
|
||||||
|
"vite-tsconfig-paths": "^4.3.2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {Fragment, h} from 'preact'
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p>Hello Vite + Preact!</p>
|
||||||
|
<p>
|
||||||
|
<a
|
||||||
|
className="link"
|
||||||
|
href="https://preactjs.com/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer">
|
||||||
|
Learn Preact
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
background: #FAFAFA;
|
||||||
|
font-family: 'Helvetica Neue', arial, sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #444;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
height: 100%;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #673ab8;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.5em;
|
||||||
|
padding-top: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
color: #fff;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import './index.css'
|
||||||
|
|
||||||
|
import {h, render} from 'preact'
|
||||||
|
|
||||||
|
import {App} from './app'
|
||||||
|
|
||||||
|
const root = document.getElementById('app')
|
||||||
|
if (!root) throw new Error('No root element')
|
||||||
|
render(<App />, root)
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES5",
|
||||||
|
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||||
|
"types": [],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": false,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"jsxFactory": "h",
|
||||||
|
"jsxFragmentFactory": "Fragment"
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {resolve} from 'node:path'
|
||||||
|
|
||||||
|
// @ts-expect-error - not important
|
||||||
|
import preactRefresh from '@prefresh/vite'
|
||||||
|
import type {UserConfig} from 'vite'
|
||||||
|
import paths from 'vite-tsconfig-paths'
|
||||||
|
|
||||||
|
const config: UserConfig = {
|
||||||
|
jsx: {
|
||||||
|
factory: 'h',
|
||||||
|
fragment: 'Fragment',
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
plugins: [preactRefresh(), paths()],
|
||||||
|
assetsDir: 'static/embed/assets',
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
File diff suppressed because it is too large
Load Diff
|
@ -83,11 +83,10 @@ To run the build with Go, use staging credentials, your own, or any other accoun
|
||||||
```
|
```
|
||||||
cd social-app
|
cd social-app
|
||||||
yarn && yarn build-web
|
yarn && yarn build-web
|
||||||
cp ./web-build/static/js/*.* bskyweb/static/js/
|
|
||||||
cd bskyweb/
|
cd bskyweb/
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build -v -tags timetzdata -o bskyweb ./cmd/bskyweb
|
go build -v -tags timetzdata -o bskyweb ./cmd/bskyweb
|
||||||
./bskyweb serve --pds-host=https://staging.bsky.dev --handle=<HANDLE> --password=<PASSWORD>
|
./bskyweb serve --appview-host=https://public.api.bsky.app
|
||||||
```
|
```
|
||||||
|
|
||||||
On build success, access the application at [http://localhost:8100/](http://localhost:8100/). Subsequent changes require re-running the above steps in order to be reflected.
|
On build success, access the application at [http://localhost:8100/](http://localhost:8100/). Subsequent changes require re-running the above steps in order to be reflected.
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"build-ios": "yarn use-build-number-with-bump eas build -p ios",
|
"build-ios": "yarn use-build-number-with-bump eas build -p ios",
|
||||||
"build-android": "yarn use-build-number-with-bump eas build -p android",
|
"build-android": "yarn use-build-number-with-bump eas build -p android",
|
||||||
"build": "yarn use-build-number-with-bump eas build",
|
"build": "yarn use-build-number-with-bump eas build",
|
||||||
|
"build-embed": "cd bskyembed && yarn build && cd .. && node ./scripts/post-embed-build.js",
|
||||||
"start": "expo start --dev-client",
|
"start": "expo start --dev-client",
|
||||||
"start:prod": "expo start --dev-client --no-dev --minify",
|
"start:prod": "expo start --dev-client --no-dev --minify",
|
||||||
"clean-cache": "rm -rf node_modules/.cache/babel-loader/*",
|
"clean-cache": "rm -rf node_modules/.cache/babel-loader/*",
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
// const path = require('node:path')
|
||||||
|
// const fs = require('node:fs')
|
||||||
|
|
||||||
|
// const projectRoot = path.join(__dirname, '..')
|
||||||
|
|
||||||
|
// // copy embed assets to web-build
|
||||||
|
|
||||||
|
// const embedAssetSource = path.join(
|
||||||
|
// projectRoot,
|
||||||
|
// 'bskyembed',
|
||||||
|
// 'dist',
|
||||||
|
// 'static',
|
||||||
|
// 'embed',
|
||||||
|
// 'assets',
|
||||||
|
// )
|
||||||
|
|
||||||
|
// const embedAssetDest = path.join(
|
||||||
|
// projectRoot,
|
||||||
|
// 'web-build',
|
||||||
|
// 'static',
|
||||||
|
// 'embed',
|
||||||
|
// 'assets',
|
||||||
|
// )
|
||||||
|
|
||||||
|
// fs.cpSync(embedAssetSource, embedAssetDest, {recursive: true})
|
||||||
|
|
||||||
|
// // copy entrypoint(s) to web-build
|
||||||
|
|
||||||
|
// // additional entrypoints will need more work, but this'll do for now
|
||||||
|
// const embedHtmlSource = path.join(
|
||||||
|
// projectRoot,
|
||||||
|
// 'bskyembed',
|
||||||
|
// 'dist',
|
||||||
|
// 'index.html',
|
||||||
|
// )
|
||||||
|
|
||||||
|
// const embedHtmlDest = path.join(
|
||||||
|
// projectRoot,
|
||||||
|
// 'web-build',
|
||||||
|
// 'static',
|
||||||
|
// 'embed',
|
||||||
|
// 'post.html',
|
||||||
|
// )
|
||||||
|
|
||||||
|
// fs.copyFileSync(embedHtmlSource, embedHtmlDest)
|
||||||
|
|
||||||
|
// console.log(`Copied embed assets to web-build`)
|
||||||
|
|
||||||
|
console.log('post-embed-build.js - waiting for embedr!')
|
Loading…
Reference in New Issue