adams85 / bundling Goto Github PK
View Code? Open in Web Editor NEWA library for optimizing and bundling web assets of ASP.NET Core applications.
License: MIT License
A library for optimizing and bundling web assets of ASP.NET Core applications.
License: MIT License
It is possible to use files with .vue extension ?
Hot good it works with vuejs.react.angular frameworks ?
Hi adams85,
On javascript when a variable is not declared we get System.NullReferenceException: 'Object reference not set to an instance of an object.' at VisitVariableDeclarator.
[TO REPRODUCE]
On TypeScriptDemo add to foo.ts var i, length;
just after the _timeout function.
[POSSIBLE FIX]
Execute Visit(variableDeclarator.Init) only if Init is not null
protected override void VisitVariableDeclarator(VariableDeclarator variableDeclarator)
{
if (variableDeclarator.Init != null)
{
// id skipped
Visit(variableDeclarator.Init);
}
}
Thank you
(I'm actually looking how to pull new request, sry i'm new to github)
Getting multiple errors from sentry on syntax errors after bundeling.
Just tested on iPhone 11 pro 13.2, and the not-bundeled JS works perfectly, but after bundeling gives a syntax error.
Code:
target.forEach((el)=>{ if (el.name.includes(',')) { const arr=el.name.split(','); arr.forEach((str)=>{ const sec=window.data.find(x=>x.name=== str); if (sec) { result.push(sec.id); } } ); } else { result.push(el.id); } } ); result.forEach((id)=>{ dowork(id); } ); }
Hi,
I'm not sure if this has been mentioned before. But I have a problem with Karambolo.AspNetCore.Bundling.BundlingOptions and javascript files being modified outside of Visual Studio.
If a file is modified when the solution isn't opened in Visual studio, no new version number is generated and you get an old version of the bundle when running localhost with no other way of getting a new version without adding yet another change (e.g. a space).
If it's not possible to fix within the package by you, is there a way to force it to update the version number in any way manually from Visual studio for all bundles?
We have a lot of bundles in our solution, so it's not possible to manually make a change inside of each time e.g. after a merge from another branch where several files might have been changed outside of VS.
Thx
In Asp.Net 4 we use to do bundling via BundleConfig => RegisterBundles via the following way:
foreach (var culture in languageCultures)
{
var modulesGlobalsJSBundle = new Bundle(string.Format("~/Scripts/modulesGlobalsJS-{0}", culture.code))
.Include("~/Scripts/MyModules/build/my-modules.js");
modulesGlobalsJSBundle.Transforms.Clear();
modulesGlobalsJSBundle.Transforms.Add(new JSTranslator());
modulesGlobalsJSBundle.Transforms.Add(new JsMinify());
bundles.Add(modulesGlobalsJSBundle);
}
That is, a separate bundle will be created for each culture available via list of languageCultures.
Now I can't find way in Asp.Net Core to apply transform to my static files application startup. We used JSTranslator earlier as a transform (shown in code above) for replacing any localizable strings present in .js files w.r.t current UI culture.
How can we do that using your way of Bundling and Minification?
A sample would be of great help. Thanks in advance.
Hi adams85 and thanks for this great bundling.
I'm using EcmaScript for ES6 support and it seems the whole file has being imported. Is it possible to eliminate dead code and import only what is really needed?
TO REPRODUCE THE CASE:
In TypeScriptDemo add a "treeShaking" function to foo.js. Running the application main.js will include the function, even if it has not been imported.
WHAT EXPECTED:
main.js without the "treeShaking" function.
I would like to add a version number to the URL of my bundled scripts. In my project, I'm using the asp-append-version tag, which calculates a hash and appends to the script. For all my non-bundled scripts, this tag works fine. However, when I use with a bundled script, nothing is added to the URL. See content below.
Is there a work around or something built into the bundler for append a version? I want to make sure that users' browsers don't use cached bundles when a new, updated version is available.
Source:
<script src="~/bundles/scripts/table-bundle.js" asp-append-version="true"></script> <script src="~/Scripts/clients/dashboard/dashboardPage.js" asp-append-version="true"></script>
Output:
`<script src="/bundles/scripts/table-bundle.js"></script>
Hi everyone!
I'm trying to import scss file from node_modules
in wwwroot/scss
and I'm getting this error:
[13:28:55 Warning] Karambolo.AspNetCore.Bundling.Sass.SassCompiler
Sass compilation of '/scss/main.scss' failed.
Error: File to import not found or unreadable: ../../node_modules/blip-toolkit/dist/scss/variables/module.scss.
on line 1 of scss/main.scss
>> @import "../../node_modules/blip-toolkit/dist/scss/variables/module.scss";
I've checked if path is correct and it is. Can anyone tell me if this package has some restriction to import scss files from node_modules
?
Thanks!
Hi,
First of all, what a perfect library. I use it on multiple websites I developed.
The question I have is when I use EnableCacheHeader
the client perfectly caches the bundled CSS and JS.
When I create a new deployment, I want to invalidate that cache.
Is there a way to invalidate that cache on new versions, with keeping the EnableCacheHeader
?
I've tried:
asp-append-version="true"
It'd be nice to be able to emit source maps, especially in the case of LESS/SASS/ES6 module bundles. Looks like a serious undertaking, though.
Do we have a possibility use CDN?
Are there plans to update the tools application to target .NET 7?
Currently, the tools appear to require the .NET Core 3 runtime.
I've included my command line output to show the runtimes and SDKs that are available in my local environment, as well as the output from running dotnet-bundle --version
> dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
> dotnet --list-sdks
6.0.413 [C:\Program Files\dotnet\sdk]
7.0.201 [C:\Program Files\dotnet\sdk]
7.0.307 [C:\Program Files\dotnet\sdk]
> dotnet tool install -g dotnet-bundlingtools
You can invoke the tool using the following command: dotnet-bundle
Tool 'dotnet-bundlingtools' (version '3.6.1') was successfully installed.
> dotnet-bundle --version
You must install or update .NET to run this application.
App: C:\Users\jholzer\.dotnet\tools\dotnet-bundle.exe
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '3.0.0' (x64)
.NET location: C:\Program Files\dotnet\
The following frameworks were found:
5.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.14 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.15 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.16 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.18 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.21 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
7.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
7.0.10 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.0.0&arch=x64&rid=win10-x64
Is there a way to configure the bundling to render each file individually like classic ASP.NET bundling when using <compilation debug="true" />
in the web.config?
We tried upgrading to 3.5 but received a negative number error on List creation. It was spawned from this method. I'm assuming 0 items come back which then results in -1.
I am converting an older project from Asp.Net MVC 4 and found your library. I figured I would go straight with .net core 3 however there have been a couple of issues.
Microsft has deprecated the IHostingEnvironment in favour of IWebHostEnvironment. This means the UseDefaults extension method doesn't work.
Also, when running the project I get a method not found exception
Method not found: 'Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware
Let me know if I can provide more info.
Thanks
I have an ASP.NET WebForms WebSite project. Will this component work such project for bundling and minification?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.