diff --git a/examples/example-workspace/app1/public/index.html b/examples/example-workspace/app1/public/index.html new file mode 100644 index 0000000..aa2968a --- /dev/null +++ b/examples/example-workspace/app1/public/index.html @@ -0,0 +1,9 @@ + + + + App1 + + + + + \ No newline at end of file diff --git a/examples/example-workspace/app1/src/main.js b/examples/example-workspace/app1/src/main.js new file mode 100644 index 0000000..c25396e --- /dev/null +++ b/examples/example-workspace/app1/src/main.js @@ -0,0 +1,5 @@ +document.body.textContent = 'Hello World - App1'; + +module.hot.accept(() => { + window.location.reload(); +}); \ No newline at end of file diff --git a/examples/example-workspace/app2/public/index.html b/examples/example-workspace/app2/public/index.html new file mode 100644 index 0000000..4418475 --- /dev/null +++ b/examples/example-workspace/app2/public/index.html @@ -0,0 +1,9 @@ + + + + App2 + + + + + \ No newline at end of file diff --git a/examples/example-workspace/app2/src/main.js b/examples/example-workspace/app2/src/main.js new file mode 100644 index 0000000..028f702 --- /dev/null +++ b/examples/example-workspace/app2/src/main.js @@ -0,0 +1,5 @@ +document.body.textContent = 'Hello World - App2'; + +module.hot.accept(() => { + window.location.reload(); +}); \ No newline at end of file diff --git a/examples/example-workspace/scripts/.nolluprc.js b/examples/example-workspace/scripts/.nolluprc.js new file mode 100644 index 0000000..c5e5c0b --- /dev/null +++ b/examples/example-workspace/scripts/.nolluprc.js @@ -0,0 +1,5 @@ +module.exports = { + hot: true, + port: 9001, + contentBase: `../${process.env.APP_TARGET}/public` +}; \ No newline at end of file diff --git a/examples/example-workspace/scripts/package.json b/examples/example-workspace/scripts/package.json new file mode 100644 index 0000000..c8f7059 --- /dev/null +++ b/examples/example-workspace/scripts/package.json @@ -0,0 +1,11 @@ +{ + "scripts": { + "dev:app1": "NODE_ENV=development APP_TARGET=app1 node ../../../lib/cli.js -c", + "dev:app2": "NODE_ENV=development APP_TARGET=app2 node ../../../lib/cli.js -c", + "build:app1": "NODE_ENV=production APP_TARGET=app1 rollup -c --watch", + "build:app2": "NODE_ENV=production APP_TARGET=app2 rollup -c --watch" + }, + "devDependencies": { + "rollup": "^3.11.0" + } +} diff --git a/examples/example-workspace/scripts/rollup.config.js b/examples/example-workspace/scripts/rollup.config.js new file mode 100644 index 0000000..e887ad5 --- /dev/null +++ b/examples/example-workspace/scripts/rollup.config.js @@ -0,0 +1,8 @@ +module.exports = { + input: `../${process.env.APP_TARGET}/src/main.js`, + output: { + dir: 'dist', + format: 'esm', + entryFileNames: '[name].js' + } +} \ No newline at end of file diff --git a/lib/dev-middleware.js b/lib/dev-middleware.js index 6bff5d7..209531e 100644 --- a/lib/dev-middleware.js +++ b/lib/dev-middleware.js @@ -117,7 +117,19 @@ module.exports = function (app, config, options, server) { } (async function () { + function extraWatch() { + return { + buildEnd() { + let files = this.getWatchFiles(); + watcher.add(files); + } + } + } + for (let i = 0; i < configs.length; i++) { + configs[i].plugins = configs[i].plugins || []; + configs[i].plugins.push(extraWatch()); + let bundle = await nollup(configs[i]); bundle.configure(options); // live-bindings config bundles.push(bundle); diff --git a/test/cases/DevMiddleware.js b/test/cases/DevMiddleware.js index 8a2cfe4..f4e08e1 100644 --- a/test/cases/DevMiddleware.js +++ b/test/cases/DevMiddleware.js @@ -11,6 +11,10 @@ let chokidar = { return { on: (event, callback) => { this._callbacks.push({ event, callback }); + }, + + add() { + } } },