You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once Webpack has been configured, run `npm run build` to build the bundles. Once you have verified that the bundle is being created correctly, you can modify your ReactJS.NET configuration (normally `App_Start\ReactConfig.cs`) to load the newly-created bundle.
47
47
48
+
Reference the runtime, vendor, and main app bundles that were generated:
This will load all your components into the `Components` global, which can be used from `Html.React` to render any of the components:
@@ -71,11 +73,44 @@ Reference the built bundle directly in a script tag at the end of the page in `_
71
73
// at the top of your layout
72
74
@using React.AspNet
73
75
74
-
// before the closing </body> tag
75
-
<scriptsrc="/dist/runtime.js"></script>
76
-
<scriptsrc="/dist/vendor.js"></script>
77
-
<scriptsrc="/dist/components.js"></script>
78
-
@Html.ReactInitJavaScript()
76
+
<head>
77
+
<linkrel="stylesheet"href="/dist/main.css">
78
+
</head>
79
+
<body>
80
+
@RenderBody()
81
+
<scriptsrc="/dist/runtime.js"></script>
82
+
<scriptsrc="/dist/vendor.js"></script>
83
+
<scriptsrc="/dist/main.js"></script>
84
+
@Html.ReactInitJavascript()
85
+
</body>
79
86
```
80
87
81
88
A full example is available in [the ReactJS.NET repository](https://github.com/reactjs/React.NET/tree/master/src/React.Sample.Webpack.CoreMvc).
89
+
90
+
### 💡 Beta feature: Asset manifest handling
91
+
92
+
An asset manifest is generated by the `webpack-asset-manifest` plugin, written to `asset-manifest.json`. See the webpack config example above for details on how to set this up. This manifest file contains a list of all of the bundles required to run your app. To use it, call `.SetReactAppBuildPath("~/dist")`. You may still provide exact paths to additional scripts by calling `AddScriptWithoutTransform("~/dist/path-to-your-file.js")`.
93
+
94
+
```csharp
95
+
ReactSiteConfiguration.Configuration
96
+
.SetLoadBabel(false)
97
+
.SetLoadReact(false)
98
+
.SetReactAppBuildPath("~/dist");
99
+
```
100
+
101
+
Then, make calls to `@Html.ReactGetScriptPaths()` and `@Html.ReactGetStylePaths()` where you would normally reference styles and scripts from your layout.
0 commit comments