mirror of https://github.com/Kylart/KawAnime.git
Added serverStart to enable hot reloading on server.
This commit is contained in:
parent
e1d6e35c72
commit
1438aea177
|
@ -66,11 +66,17 @@ npm run bstart
|
|||
|
||||
## Run in dev
|
||||
|
||||
##### Start
|
||||
##### Start all app
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
#### Start only server with hot reloading
|
||||
_using this with a REST api client is kinda useful_.
|
||||
```
|
||||
npm run dev:server
|
||||
```
|
||||
|
||||
##### Lint
|
||||
```
|
||||
npm run lint
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* Created by Kylart on 19/06/2017.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
process.NODE_ENV = 'development'
|
||||
|
||||
const {join} = require('path')
|
||||
const Nuxt = require('nuxt')
|
||||
const http = require('http')
|
||||
const chokidar = require('chokidar')
|
||||
|
||||
let nuxt = null
|
||||
let server = null
|
||||
|
||||
const initServer = async () => {
|
||||
const initFile = require(join(__dirname, '..', 'assets', 'api', 'main.js'))
|
||||
|
||||
/**
|
||||
* Nuxt config
|
||||
*/
|
||||
const config = require('../nuxt.config.js')
|
||||
|
||||
/**
|
||||
* Server config
|
||||
*/
|
||||
nuxt = new Nuxt(config)
|
||||
const route = initFile.route(nuxt)
|
||||
server = http.createServer(route)
|
||||
|
||||
await nuxt.build()
|
||||
server.listen(3000)
|
||||
}
|
||||
|
||||
initServer()
|
||||
|
||||
chokidar.watch(join(__dirname), {ignored: './menu.js'}).on('all', (event, path) => {
|
||||
console.info(`${path}: ${event}`)
|
||||
|
||||
server.close()
|
||||
|
||||
initServer().catch((err) => { void err })
|
||||
})
|
|
@ -11,6 +11,7 @@
|
|||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "cross-env NODE_ENV=development electron .",
|
||||
"dev:server": "node assets/serverStart.js",
|
||||
"cloc": "cloc $(git ls-files | grep -vE \".mkv|mp4|lock\")",
|
||||
"test:server": "nyc ava --verbose --serial test/server.test.js",
|
||||
"test:front": "nightwatch",
|
||||
|
@ -101,7 +102,8 @@
|
|||
"nightwatch.conf.js",
|
||||
"**/*.test.js",
|
||||
"**/node_modules/**",
|
||||
"**/openExternal.js"
|
||||
"**/openExternal.js",
|
||||
"assets/serverStart.js"
|
||||
],
|
||||
"watermarks": {
|
||||
"lines": [
|
||||
|
|
Loading…
Reference in New Issue