我想在反馈样板中使用快速js实例的webpack的多个入口点,用于具有可共享代码库的两个不同应用程序
我有两个html和两个js文件
vendor.html for vendor.js和 settings.html用于settings.js。
一个带有两个express
实例的Server.js`的 Server.js
const appVendor = express();
const appSetting = express();
setup(appVendor, {
domain: 'Vendor',
outputPath: resolve(process.cwd(), 'build_vendor'),
publicPath: '/',
});
setup(appSetting, {
domain: 'Setting',
outputPath: resolve(process.cwd(), 'build_setting'),
publicPath: '/',
});
// Start your Vendor app.
appVendor.listen('3000', host, (err) => {
if (err) {
return logger.error(err.message);
}
console.log('Server listing to port ', 3000);
});
// Start your Setting app.
appSetting.listen('5000', host, (err) => {
if (err) {
return logger.error(err.message);
}
console.log('Server listing to port ', 5000);
});
webpack.dev.babel.js
const plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: 'app/indexVendor.html',
chunk: ['vendor'],
}),
new HtmlWebpackPlugin({
template: 'app/indexSetting.html',
chunk: ['setting'],
}),
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/,
failOnError: false,
}),
];
if (dllPlugin) {
glob.sync(`${dllPlugin.path}/*.dll.js`).forEach((dllPath) => {
plugins.push(new AddAssetHtmlPlugin({
filepath: dllPath,
includeSourcemap: false,
}));
});
}
module.exports = require('./webpack.base.babel')({
entry: {
vendor: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
path.join(process.cwd(), 'app/appVendor.js'),
],
setting: [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
path.join(process.cwd(), 'app/appSetting.js'),
],
},
output: {
// path: path.resolve(__dirname, 'build'),
filename: '[name].js',
chunkFilename: '[name].chunk.js',
},
// Add development plugins
plugins: dependencyHandlers().concat(plugins),
// Emit a source map for easier debugging
// See https://webpack.js.org/configuration/devtool/#devtool
devtool: 'eval-source-map',
performance: {
hints: false,
},
});
如何与webpack多个入口点通信server.js(IP和端口)