Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 845aa8d

Browse files
committed
chore(package): remove nuxtent binary
BREAKING CHANGE: replace `nuxtent generate` by `nuxt generate` in your project's package.json scripts
1 parent 79edcc7 commit 845aa8d

File tree

4 files changed

+17
-104
lines changed

4 files changed

+17
-104
lines changed

bin/nuxtent

Lines changed: 0 additions & 26 deletions
This file was deleted.

bin/nuxtent-generate

Lines changed: 0 additions & 74 deletions
This file was deleted.

lib/module.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { resolve, join } from 'path'
22

3+
import express from 'express'
4+
35
import pkg from '../package.json'
46

57
import createRouter from './content/api'
@@ -49,6 +51,7 @@ export default function ContentModule (moduleOpts) {
4951
componentsDir: '/components',
5052
buildDir: `/content`,
5153
isStatic: userOptions.isStatic || process.env.STATIC || false,
54+
port: process.env.PORT || process.env.npm_package_config_nuxt_port || 3000,
5255

5356
content: contentOptions(userOptions.content, {
5457
page: null,
@@ -98,10 +101,23 @@ export default function ContentModule (moduleOpts) {
98101
})
99102

100103
// 2. Add content API
104+
const router = createRouter(options)
101105

106+
// Add API when running `nuxt` & `nuxt build` (development and production)
102107
this.addServerMiddleware({
103108
path: api.serverPrefix,
104-
handler: createRouter(options)
109+
handler: router
110+
})
111+
112+
// Add API when running `nuxt generate`
113+
this.nuxt.plugin('generator', generator => {
114+
const app = express()
115+
app.use(api.serverPrefix, router)
116+
const server = app.listen(options.port)
117+
118+
generator.plugin('generated', () => {
119+
server.close()
120+
})
105121
})
106122

107123
// 3. Add request helpers

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
"Static"
2323
],
2424
"license": "MIT ",
25-
"bin": {
26-
"nuxtent": "bin/nuxtent"
27-
},
2825
"scripts": {
2926
"#<git hooks>": "handled by husky",
3027
"precommit": "lint-staged",

0 commit comments

Comments
 (0)