1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-21 21:09:22 +00:00

Add live reload

This commit is contained in:
Pierre HUBERT 2019-11-21 17:20:21 +01:00
parent 8848665525
commit 5584a2ebe1
4 changed files with 745 additions and 4 deletions

722
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@
"name": "api-v2",
"version": "1.0.0",
"description": "New API for Comunic",
"main": "index.js",
"main": "build/index.js",
"scripts": {
"run": "tsc && node dist/main.js"
"run": "node dist/index.js"
},
"author": "",
"license": "MIT",
@ -13,7 +13,10 @@
},
"devDependencies": {
"@types/node": "^12.12.8",
"nodemon": "^2.0.0",
"ts-loader": "^6.0.3",
"webpack": "^4.41.2"
"webpack": "^4.41.2",
"webpack-node-externals": "^1.7.2",
"webpack-shell-plugin": "^0.5.0"
}
}

View File

@ -9,4 +9,4 @@ import { ConfigurationHelper, conf } from "./helpers/ConfigHelper";
console.info("Comunic API v6\t@author Pierre HUBERT\t2019-" + new Date().getFullYear());
console.info("Load configuration...");
ConfigurationHelper.loadConf("config.json");
ConfigurationHelper.loadConf("config.json");

View File

@ -1,4 +1,6 @@
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const WebpackShellPlugin = require("webpack-shell-plugin");
const {
NODE_ENV = 'production'
@ -18,6 +20,8 @@ module.exports = {
module: {
rules: [
// Support for TS files
{
test: /\.ts$/,
use: [
@ -27,6 +31,18 @@ module.exports = {
]
},
plugins: [
// Allow live-reload
new WebpackShellPlugin({
onBuildEnd: ["node_modules/.bin/nodemon build/main.js"]
})
],
// Split dependencies and source code
externals: [nodeExternals()],
// Auto-watch in dev env
watch: NODE_ENV === 'development'
}