[improvement] examples (#264)
* Example project, fix bugs in readonly mode * Adds ui options
This commit is contained in:
parent
2441ca0c90
commit
fa38c0ef0d
25 changed files with 1566 additions and 731 deletions
|
@ -1,19 +1,13 @@
|
|||
/* eslint-disable */
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import esbuild from 'esbuild'
|
||||
import dotenv from 'dotenv'
|
||||
import { createRequire } from 'module'
|
||||
|
||||
const pkg = createRequire(import.meta.url)('../package.json')
|
||||
|
||||
async function main() {
|
||||
if (fs.existsSync('./dist')) {
|
||||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
esbuild.buildSync({
|
||||
entryPoints: ['./src/index.tsx'],
|
||||
|
@ -27,15 +21,17 @@ async function main() {
|
|||
tsconfig: './tsconfig.json',
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
'process.env.LIVEBLOCKS_PUBLIC_API_KEY': `"${process.env.LIVEBLOCKS_PUBLIC_API_KEY}"`,
|
||||
},
|
||||
metafile: false,
|
||||
sourcemap: false,
|
||||
})
|
||||
|
||||
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
|
||||
fs.readdirSync('./src/public').forEach((file) =>
|
||||
fs.copyFile(path.join('./src/public', file), path.join('./dist', file), (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
)
|
||||
console.log(`✔ ${pkg.name}: Build completed.`)
|
||||
} catch (e) {
|
||||
console.log(`× ${pkg.name}: Build failed due to an error.`)
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
/* eslint-disable no-undef */
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import esbuildServe from 'esbuild-serve'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
async function main() {
|
||||
if (!fs.existsSync('./dist')) {
|
||||
fs.mkdirSync('./dist')
|
||||
if (fs.existsSync('./dist')) {
|
||||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
fs.mkdirSync('./dist')
|
||||
|
||||
fs.readdirSync('./src/public').forEach((file) =>
|
||||
fs.copyFile(path.join('./src/public', file), path.join('./dist', file), (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
)
|
||||
|
||||
try {
|
||||
await esbuildServe(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue