Skip to content

Commit

Permalink
Merge branch 'remix-v2' of github.com:oxidecomputer/rfd-site into rem…
Browse files Browse the repository at this point in the history
…ix-v2
  • Loading branch information
benjaminleonard committed Oct 18, 2024
2 parents 08f9dbf + f658e76 commit 7f42e02
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/services/rfd.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Octokit } from 'octokit'
import { generateAuthors, type Author } from '~/components/rfd/RfdPreview'
import { isTruthy } from '~/utils/isTruthy'
import { parseRfdNum } from '~/utils/parseRfdNum'
import { can, Permission } from '~/utils/permission'
import { can, type Permission } from '~/utils/permission'
import type { GroupResponse, RfdListResponseItem, RfdResponse } from '~/utils/rfdApi'

import type { Group, User } from './authn.server'
Expand Down
14 changes: 8 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import { vercelPreset } from '@vercel/remix/vite'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'

import { LocalRfdPlugin } from './vite/local-rfd-plugin'

const plugins = [remix({ presets: [vercelPreset()] }), tsconfigPaths()]

const localRepo = process.env.LOCAL_RFD_REPO
if (localRepo) plugins.push(LocalRfdPlugin(localRepo))

export default defineConfig({
plugins: [remix({ presets: [vercelPreset()] }), tsconfigPaths()],
plugins,
server: {
watch: {
ignored: process.env.LOCAL_RFD_REPO
? ['!**/node_modules/**', `!${process.env.LOCAL_RFD_REPO}/rfd/**`]
: ['!**/node_modules/**'],
},
port: 3000,
},
})
34 changes: 34 additions & 0 deletions vite/local-rfd-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/

import fs from 'node:fs'
import path from 'node:path'
import { type Plugin } from 'vite'

export function LocalRfdPlugin(localRepo: string): Plugin {
return {
name: 'vite-plugin-local-rfd',
buildStart() {
// blow up if it doesn't exist
fs.stat(localRepo, (err) => {
if (err) {
console.error(`Error: LOCAL_RFD_REPO ${localRepo} does not exist`)
process.exit(1)
}
})
this.addWatchFile(path.join(localRepo, 'rfd'))
},
handleHotUpdate(ctx) {
if (ctx.file.startsWith(localRepo)) {
ctx.server.config.logger.info(`reloading: ${ctx.file} changed`)
// bit of a hack but I'm not sure what else to do
ctx.server.ws.send({ type: 'full-reload', path: 'app/services/rfd.server.ts' })
}
},
}
}

0 comments on commit 7f42e02

Please sign in to comment.