webpack.net's Issues
Compatibility with react-create-app
Hi, I'm trying to use this library with create-react-app, without ejecting the project.
The issue with this is that I cannot modify webpack.config (in fact I don't even have one in my app folder), and it uses webpack-manifest-plugin instead of assets-webpack-plugin, which produces an asset mapping file with a different structure.
I'm forking the project since I need to have it working fast with my use case - and BTW, thanks for this, there are plenty of webpack/react integrations with .NET Core, pretty much none for .NET 4.x - but if you're interested we could think of a configurable definition for the asset json.
AssetUrl call crashes with Server operation is not available in this context.
- The issue is related to Sitecore 9 application. App is hosted locally on IIS 10 with integrated v4.0 application pool. I did check with standard ASP.NET MVC app and it should work fine (details in 4.; similar deployment settings).
- Webpack configuration is done via sitecore's initialize pipeline. This is a substitute for Application_Start and works fine with all initializations that I have. Configuration code:
private void RegisterWebpack()
{
var applicationInstance = HttpContext.Current.ApplicationInstance;
applicationInstance.ConfigureWebpack(new WebpackConfig
{
AssetManifestPath = "~/webpack-assets.json",
AssetOutputPath = "~/",
});
}
- Build succeeds, but when trying to enter website, application crashes with exception
[HttpException (0x80004005): Server operation is not available in this context.]
System.Web.HttpServerUtility.MapPath(String path) +225
Webpack.NET.Webpack.GetAssetDictionaryForConfig(WebpackConfig configuration, HttpServerUtilityBase httpServerUtility) +26
System.Linq.WhereSelectArrayIterator`2.MoveNext() +78
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +436
System.Linq.Enumerable.ToList(IEnumerable`1 source) +70
System.Lazy`1.CreateValue() +708
System.Lazy`1.LazyInitValue() +184
Webpack.NET.Webpack.GetAssetUrl(String assetName, String assetType, Boolean required) +101
Webpack.NET.UrlHelperExtensions.WebpackAsset(UrlHelper urlHelper, String assetName, String assetType, Boolean required) +87
ASP._Page_Views_Shared__Default_cshtml.Execute() in [full local path here]\Views\Shared\_Default.cshtml:17
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +136
Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +257
- I did some digging and found out that applicationInstance used in registration has Server property with null assigned to _context. This propagates into HttpServerUtility.MapPath and crashes as this method requires _context field to exist. In standard ASP.NET MVC app this _context is filled at Application_Start.
- When I move the code from initialize pipeline's handler directly to _Default.cshtml then everything works fine, because at this point HttpContext.Current.ApplicationInstance.Server contains _context with proper object assigned.
- I found out a suggestion (here) to use System.Web.Hosting.HostingEnvironment.MapPath method instead of HttpServerUtility.MapPath, because it does not require HttpContext and under the hood HttpServerUtility.MapPath reaches to suggested method.
css caching
Is there any plan to support load and injection of css chunked file names;
UrlHelper not registering
I got everything setup in Global.asax but in the .cshtml file, the error occurs
'UrlHelper' does not contain a definition for 'WebpackAsset' and no extension method 'WebpackAsset' accepting a first argument of type 'UrlHelper' could be found (are you missing a using directive or an assembly reference?)
Any idea why the extension isn't registering?
Reload on manifest change
Loading the manifest file is already done lazily, but when the file changes, not reloaded. The website must now be restarted to pick up the changes.
Adding a ReloadOnChange
boolean property to the WebpackConfig
class with a default value of false
would keep it backwards compatible and an opt-in feature per manifest (and in line with ASP.NET Core conventions for configuration files).
The reloading could be done by using a FileSystemWatcher
and subscribing to the Changed
event.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.