mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-22 17:24:15 +01:00
2069c4cd8b
* fix dayjs
* fix timeouts (we're not strictly speaking running in nodejs)
* export unexported type
* consolidate on a single FormInstance
* no need to rename
* fuse
* forminstance 2
* locationChanged
* BuiltLogic
* remove Type.ts exception
* fix duh
* playing with common apps
* playing with common apps
* fix some scss deprecations 🤷
* revert
* move packages/apps-common
* remove compiled json file
* build apps-common before other packages
* mkdirp, build types before running
* build types before the rest
* move imports json to packages folder
* mark some packages as external, saving 200kb
* revert nonsense
* remove ant dep
* make app source editor types optional for speed
* move dev server reloads to utils.mjs
* remove webpack start scripts (unused)
* refactor build/utils to support various dirs
* apps package
* revert some stuff
* yarn
* go back to the old location and commit packages.json in
* commit it in
* out of scope
* fix bad imports
* fix some postcss mess
* move to @posthog/apps-common
* add more stuff to apps
* include that in packages.json
* simple cjs build
* export everything
* simplify
* make separate package for lemonade
* more lemonade
* fix jest imports
* fix jest imports
* yarn as well
* src
* write types before building
* rename lemon-ui, part 1
* add readmes
* rename to lemon-ui, part 2
* this app source editor tsd is committed into the repo, so we don't need it before a build
107 lines
3.2 KiB
JavaScript
Executable File
107 lines
3.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import * as path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import {
|
|
copyPublicFolder,
|
|
isDev,
|
|
startDevServer,
|
|
createHashlessEntrypoints,
|
|
buildInParallel,
|
|
copyIndexHtml,
|
|
} from './utils.mjs'
|
|
|
|
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
startDevServer(__dirname)
|
|
copyPublicFolder(path.resolve(__dirname, 'public'), path.resolve(__dirname, 'dist'))
|
|
writeIndexHtml()
|
|
writeSharedDashboardHtml()
|
|
|
|
const common = {
|
|
absWorkingDir: __dirname,
|
|
bundle: true,
|
|
}
|
|
|
|
await buildInParallel(
|
|
[
|
|
{
|
|
name: 'PostHog App',
|
|
absWorkingDir: __dirname,
|
|
entryPoints: ['src/index.tsx'],
|
|
splitting: true,
|
|
format: 'esm',
|
|
outdir: path.resolve(__dirname, 'dist'),
|
|
...common,
|
|
},
|
|
{
|
|
name: 'Shared Dashboard',
|
|
absWorkingDir: __dirname,
|
|
entryPoints: ['src/scenes/dashboard/SharedDashboard.tsx'],
|
|
format: 'iife',
|
|
outfile: path.resolve(__dirname, 'dist', 'shared_dashboard.js'),
|
|
...common,
|
|
},
|
|
{
|
|
name: 'Exporter',
|
|
absWorkingDir: __dirname,
|
|
entryPoints: ['src/exporter/ExportViewer.tsx'],
|
|
format: 'iife',
|
|
outfile: path.resolve(__dirname, 'dist', 'exporter.js'),
|
|
...common,
|
|
},
|
|
{
|
|
name: 'Toolbar',
|
|
absWorkingDir: __dirname,
|
|
entryPoints: ['src/toolbar/index.tsx'],
|
|
format: 'iife',
|
|
outfile: path.resolve(__dirname, 'dist', 'toolbar.js'),
|
|
...common,
|
|
},
|
|
],
|
|
{
|
|
async onBuildComplete(config, buildResponse) {
|
|
const { chunks, entrypoints } = buildResponse
|
|
|
|
if (config.name === 'PostHog App') {
|
|
if (Object.keys(chunks).length === 0) {
|
|
throw new Error('Could not get chunk metadata for bundle "PostHog App."')
|
|
}
|
|
if (!isDev && Object.keys(entrypoints).length === 0) {
|
|
throw new Error('Could not get entrypoint for bundle "PostHog App."')
|
|
}
|
|
writeIndexHtml(chunks, entrypoints)
|
|
}
|
|
|
|
if (config.name === 'Shared Dashboard') {
|
|
writeSharedDashboardHtml(chunks, entrypoints)
|
|
}
|
|
|
|
if (config.name === 'Exporter') {
|
|
writeExporterHtml(chunks, entrypoints)
|
|
}
|
|
|
|
createHashlessEntrypoints(__dirname, entrypoints)
|
|
},
|
|
}
|
|
)
|
|
|
|
export function writeIndexHtml(chunks = {}, entrypoints = []) {
|
|
copyIndexHtml(__dirname, 'src/index.html', 'dist/index.html', 'index', chunks, entrypoints)
|
|
copyIndexHtml(__dirname, 'src/layout.html', 'dist/layout.html', 'index', chunks, entrypoints)
|
|
}
|
|
|
|
export function writeSharedDashboardHtml(chunks = {}, entrypoints = []) {
|
|
copyIndexHtml(
|
|
__dirname,
|
|
'src/shared_dashboard.html',
|
|
'dist/shared_dashboard.html',
|
|
'shared_dashboard',
|
|
chunks,
|
|
entrypoints
|
|
)
|
|
}
|
|
|
|
export function writeExporterHtml(chunks = {}, entrypoints = []) {
|
|
copyIndexHtml(__dirname, 'src/exporter.html', 'dist/exporter.html', 'exporter', chunks, entrypoints)
|
|
}
|