Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
feat(webpack-backend): Nodemon for dev hook
Browse files Browse the repository at this point in the history
  • Loading branch information
IniZio committed Jan 2, 2018
1 parent ac2458e commit 1cf5402
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 13 deletions.
37 changes: 36 additions & 1 deletion presets/webpack-backend/clipped.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
module.exports = clipped => clipped.use(require('clipped-preset-webpack-nodejs'))
const path = require('path')
const fs = require('fs')
const nodemon = require('nodemon')

module.exports = async clipped => {
await clipped.use(require('clipped-preset-webpack-nodejs'))

let mainFile = path.join(clipped.config.context, clipped.config.packageJson.main)
try {
require(mainFile)
} catch (e) {
mainFile = null
}

clipped.hook('dev')
.add('watch and nodemon', [
clipped => clipped.execHook('watch'),
clipped => new Promise((resolve, reject) => {
nodemon({
// Main field in package.json or dist/index.js
script: mainFile || clipped.config.main || path.join(clipped.config.dist, 'index.js'),
ext: 'js json',
ignore: ["test/*", "docs/*"]
})

nodemon.on('start', function () {
console.log('> App has started')
}).on('quit', function () {
console.log('> App has quit')
process.exit();
}).on('restart', function (files) {
console.log('> App restarted due to: ', files)
})
})
])
}
5 changes: 3 additions & 2 deletions presets/webpack-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clipped-preset-webpack-backend",
"version": "0.3.1",
"version": "0.4.1",
"description": "",
"main": "clipped.config.js",
"scripts": {
Expand All @@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"clipped-preset-webpack-nodejs": "^0.1.2"
"clipped-preset-webpack-nodejs": "^0.1.2",
"nodemon": "^1.14.7"
}
}
Loading

0 comments on commit 1cf5402

Please sign in to comment.