1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19: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", "name": "api-v2",
"version": "1.0.0", "version": "1.0.0",
"description": "New API for Comunic", "description": "New API for Comunic",
"main": "index.js", "main": "build/index.js",
"scripts": { "scripts": {
"run": "tsc && node dist/main.js" "run": "node dist/index.js"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
@ -13,7 +13,10 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^12.12.8", "@types/node": "^12.12.8",
"nodemon": "^2.0.0",
"ts-loader": "^6.0.3", "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

@ -1,4 +1,6 @@
const path = require("path"); const path = require("path");
const nodeExternals = require("webpack-node-externals");
const WebpackShellPlugin = require("webpack-shell-plugin");
const { const {
NODE_ENV = 'production' NODE_ENV = 'production'
@ -18,6 +20,8 @@ module.exports = {
module: { module: {
rules: [ rules: [
// Support for TS files
{ {
test: /\.ts$/, test: /\.ts$/,
use: [ 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' watch: NODE_ENV === 'development'
} }