mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Re-add server-side prerendering to Angular2 template
This commit is contained in:
@@ -31,6 +31,22 @@ function loadViaWebpackNoCache(webpackConfigPath, modulePath) {
|
||||
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
|
||||
});
|
||||
|
||||
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
||||
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
||||
// work, because then you'd get different module instances depending on whether a module
|
||||
// was referenced via a normal CommonJS 'require' or via Webpack. So just remove any
|
||||
// DllReferencePlugin from the config.
|
||||
// If someone wanted to load their own DLL modules (not an NPM module) via DllReferencePlugin,
|
||||
// that scenario is not supported today. We would have to add some extra option to the
|
||||
// asp-prerender tag helper to let you specify a list of DLL bundles that should be evaluated
|
||||
// in this context. But even then you'd need special DLL builds for the Node environment so that
|
||||
// external dependencies were fetched via CommonJS requires, so it's unclear how that could work.
|
||||
// The ultimate escape hatch here is just prebuilding your code as part of the application build
|
||||
// and *not* using asp-prerender-webpack-config at all, then you can do anything you want.
|
||||
webpackConfig.plugins = webpackConfig.plugins.filter(function(plugin) {
|
||||
return !(plugin instanceof webpack.DllReferencePlugin);
|
||||
});
|
||||
|
||||
// Create a compiler instance that stores its output in memory, then load its output
|
||||
var compiler = webpack(webpackConfig);
|
||||
compiler.outputFileSystem = new MemoryFS();
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<app>Loading...</app>
|
||||
<app asp-prerender-module="ClientApp/boot-server"
|
||||
asp-prerender-webpack-config="webpack.config.js">Loading...</app>
|
||||
|
||||
<script src="~/dist/vendor.js" asp-append-version="true"></script>
|
||||
@section scripts {
|
||||
|
||||
Reference in New Issue
Block a user