1.0.0-beta.3 • Published 7 years ago
@phylum/webpack-node v1.0.0-beta.3
Webpack Node Task
This package exposes a task that runs a node process for webpack bundled code and supports hot module replacement.
Installation
npm i webpack @phylum/webpack @phylum/webpack-nodeUsage
The webpack node task runs a node process from bundled sources. Note, that the webpack task will not be started automatically by the webpack node task.
import { Task } from '@phylum/pipeline';
import { WebpackTask } from '@phylum/webpack';
import { WebpackNodeTask } from '@phylum/webpack-node';
const bundle = new WebpackTask(...);
const node = new WebpackNodeTask(Task.value({
	main: bundle
}));
new Task(async t => {
	// Run the webpack compiler:
	await t.use(bundle);
	// Start a node process:
	await t.use(node);
});Note that the node task assumes, that the main bundle has already been compiled.
Hot Module Replacement
new WebpackNodeTask(Task.value({
	// Enable hot module replacement:
	mainHmr: true,
	main: bundle
}));// Import the hmr client somewhere in your main process code...
import '@phylum/webpack-node/dist/hmr';// ...or add it to your entry point:
entry: ['@phylum/webpack-node/dist/hmr', './src/main.js'],
// Optional. Include the hmr runtime:
plugins: [
	new webpack.HotModuleReplacementPlugin()
]If the hmr runtime is not included or an update is rejected, the main process will be rebooted.