You will need two webpack compilers, one is for server-side rendering, the other one is for client-side app.
yarn add unipack
# peer dependencies
yarn add webpack webpack-dev-server
const webpack = require('webpack')
const unipack = require('unipack')
const pack = unipack({
serverCompiler: webpack(serverWebpackConfig)
clientCompiler: webpack(clientWebpackConfig),
})
// Built both
pack.build()
// Run both in dev mode
// Run server compiler in watch mode
// Run client compiler with a dev server
pack.start({
host,
port,
devServerOptions,
watchOption
})
// Then you will have:
pack.devServer // express app
pack.devServerInstance // `net.Server` instance
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
unipack © egoist, Released under the MIT License. Authored and maintained by egoist with help from contributors (list).
egoist.moe · GitHub @egoist · Twitter @_egoistlily