Skip to content

Commit

Permalink
🐛 (admin) add env for BUILD_ADMIN, so it only runs in local env
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed May 17, 2021
1 parent f39d655 commit 2578aaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docus",
"version": "0.4.1",
"version": "0.4.14",
"repository": "nuxtlabs/docus",
"license": "GPL-3.0",
"exports": {
Expand Down Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"build": "rm -rf dist && siroc build",
"dev": "nuxt dev docs",
"dev": "BUILD_ADMIN=true nuxt dev docs",
"dev:admin": "vite --config src/admin/vite.config.ts",
"generate": "nuxt generate --force-build docs",
"start": "nuxt start docs",
Expand All @@ -49,15 +49,15 @@
"@docsearch/css": "^1.0.0-alpha.28",
"@docsearch/js": "^1.0.0-alpha.28",
"@lokidb/loki": "^2.1.0",
"@nuxt/image": "^0.4.8",
"@nuxt/image": "^0.4.10",
"@nuxtjs/color-mode": "^2.0.5",
"@nuxtjs/composition-api": "0.23.3",
"@nuxtjs/proxy": "^2.1.0",
"@nuxtjs/pwa": "^3.3.5",
"@types/graceful-fs": "^4.1.5",
"@vitejs/plugin-vue": "^1.2.2",
"@vue/composition-api": "^1.0.0-rc.8",
"@vueuse/integrations": "^4.9.4",
"@vueuse/integrations": "^4.11.0",
"clear-module": "^4.1.1",
"clipboard": "^2.0.8",
"color": "^3.1.3",
Expand All @@ -73,11 +73,11 @@
"mande": "^1.0.0",
"marked": "^2.0.3",
"mkdirp": "^1.0.4",
"nuxt-edge": "^2.16.0-27012971.cd1fc627",
"nuxt-edge": "^2.16.0-27020175.00aeff62",
"nuxt-extend": "^0.1.0",
"nuxt-i18n": "^6.27.0",
"nuxt-vite": "0.1.0",
"nuxt-windicss": "^0.7.2",
"nuxt-windicss": "0.7.1",
"ohmyfetch": "^0.1.8",
"patch-package": "^6.4.7",
"plausible-tracker": "^0.3.1",
Expand All @@ -100,7 +100,7 @@
"remark-slug": "^6.0.0",
"remark-squeeze-paragraphs": "^4.0.0",
"scule": "^0.2.1",
"siroc": "^0.10.0",
"siroc": "^0.9.3",
"theme-colors": "^0.0.5",
"ufo": "^0.6.11",
"unified": "^9.2.1",
Expand Down
8 changes: 4 additions & 4 deletions src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import serveStatic from 'serve-static'
import { Module } from '@nuxt/types'
import api from './api'

const r = (...args: string[]) => resolve(__dirname, ...args)

export default <Module>function () {
const { nuxt, addServerMiddleware, options } = this

Expand All @@ -19,8 +17,9 @@ export default <Module>function () {
handler: api
})

// TODO: Implement Vite as server middleware/proxy, so we can remove this
// Build the admin
execSync('npx vite --config src/admin/vite.config.ts build')
if (process.env.BUILD_ADMIN) execSync('npx vite --config src/admin/vite.config.ts build')

this.addServerMiddleware({
path: '/admin/',
Expand Down Expand Up @@ -50,7 +49,8 @@ export default <Module>function () {
this.requireModule('@nuxtjs/proxy')
} */

if (options.dev) this.options.plugins.push(r('runtime/plugin.ts'))
// Add runtime plugin
if (options.dev) this.options.plugins.push(require.resolve(join(__dirname, '/runtime/plugin')))

nuxt.hook('listen', (_: any, { host, port }: NuxtOptionsServer) => {
process.previewUrl = `http://${host}:${port}`
Expand Down

0 comments on commit 2578aaa

Please sign in to comment.