Giter Club home page Giter Club logo

bundling's Introduction

📣 Important notices
If you use the design-time features of the library, please note that version 3.0 switches to the Global / Local .NET Core CLI extensibility model. See the documentation for further information.

Karambolo.AspNetCore.Bundling

This library can be used to bundle and optimize web assets of ASP.NET Core 2+ applications. Primarily, it was developed as a .NET Core replacement for the System.Web.Optimization library of classic ASP.NET, which provides these features at run-time. However, starting with version 2.0, webpack-like design-time usage mode is also supported in the form of a .NET Core CLI extension tool.

NuGet Release Donate

Main features

  • CSS minification and bundling including support for CSS pre-processors:
  • JavaScript minification and bundling. Version 2.0 adds support for rewriting and bundling ES6 (ECMAScript 2015) modules (built on Acornima).
  • Straightforward and flexible configuration:
    • Fluent API configuration.
    • Hierarchical configuration system (settings adjustable on general and more detailed levels).
    • Compatibility with bundleconfig.json.
  • Full control over server and client-side caching (including cache busting). Memory and file system cache implementations are included.
  • Replaceable backing storage by leveraging .NET Core file system abstractions.
  • Automatic refresh of affected bundles on change of input files. As of version 2.0, not only the directly referenced but also the imported files are watched (in the case of LESS, SASS/SCSS and ES6 module bundles).
  • Razor tag helpers and the familiar, System.Web.Optimization-like API can be used, as well.
  • Correct handling of URL path prefixes (app branch prefix, static files middleware prefix, etc.)
  • Fully customizable transformation pipelines.
  • Dynamic content sources and query string parameterized bundles.
  • Modular design, extensibility.

Table of Contents

Quick Start

Installation

Run-time mode
1. Register bundling services
2. Define bundles
3. Configure Razor views
4. Reference bundles in Razor views

Design-time mode
1. Define bundles
2. Produce bundles

Reference
a. Bundling middleware settings
b. Bundle settings

Samples

Quick Start

If you want to get a quick overview of the capabilities of the library, check out this sample project. This is a slightly modified version of the ASP.NET Core Web App template of the .NET SDK, so you can even use it as a starting point for your web application projects.

Installation

The Karambolo.AspNetCore.Bundling package contains the core components and interfaces but no actual implementation. Therefore you need to install additional packages depending on your preferences/requirements.

Minimizer

You can choose between implementations using NUglify and WebMarkupMin currently:

dotnet add package Karambolo.AspNetCore.Bundling.NUglify

or

dotnet add package Karambolo.AspNetCore.Bundling.WebMarkupMin

CSS pre-processor

If you want to use CSS pre-processor features, you will also need one of the following packages:

  • LESS

    dotnet add package Karambolo.AspNetCore.Bundling.Less
    
  • SASS/SCSS

    dotnet add package Karambolo.AspNetCore.Bundling.Sass
    

    Note: The current implementation uses LibSassHost under the hood, which is a wrapper around LibSass, an unmanaged library written in C/C++. Therefore you need to install an additional NuGet package which contains this native dependency compiled to your target platform. E.g. on Windows x64 systems: dotnet add package LibSassHost.Native.win-x64. For further details refer to the documentation of LibSassHost.

ES6 module bundler

Finally, if you want to bundle ES6 modules, you need to install an additional package:

dotnet add package Karambolo.AspNetCore.Bundling.EcmaScript

Note: ES6 module bundling is built on Acornima, which supports language features up to ECMAScript 2023 currently. If you want to utilize even newer features (or you just want to target an older JavaScript version), you may use TypeScript for down-level compilation. (See the TypeScriptDemo sample.)

Run-time mode

Choosing this method, your bundles are built on-demand during the execution of your application. Of course, the produced bundles are cached so this is a one-time cost only. In return you get some unique features like dynamic bundles which are not possible when building bundles at design-time.

To set up run-time bundling, you need to walk through the following steps:

1. Register bundling services

Add the following to the ConfigureServices method of your Startup class:

services.AddBundling()
    .UseDefaults(Environment) // see below
    .UseNUglify() // or .UseWebMarkupMin() - whichever minifier you prefer
    .AddLess() // to enable LESS support
    .AddSass() // to enable SASS/SCSS support
    .AddEcmaScript() // to enable support for ES6 modules
    .EnableCacheHeader(TimeSpan.FromDays(1)); // to enable client-side caching

The Environment property should return the current hosting environment. You can inject it in the constructor like this:

// In versions older than ASP.NET Core 3, use IHostingEnvironment instead of IWebHostEnvironment

public IWebHostEnvironment Environment { get; }

public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
    Configuration = configuration;
    Environment = environment;
}

UseDefaults adds support for CSS and JavaScript bundles, sets up the default transformations and enables memory caching.

When hosting environment is set to Development, UseDefaults

  • enables change detection (cache invalidation on change of source files) and
  • enables including of source files instead of the actual bundled output (of course, this will apply only to bundles which allow this),

otherwise

  • enables minification.

If you want to switch to file system-backed caching, call UseFileSystemCaching() on the builder (after UseDefaults).

Besides that, there are some further settings available to tweak on the builder.

2. Define bundles

Bundles are defined in the Configure method of the Startup class in the following manner:

app.UseBundling(bundles =>
{
    // loads bundles from a BundlerMinifier config file
    bundles.LoadFromConfigFile("/bundleconfig.json", _env.ContentRootFileProvider);

    // defines a CSS bundle (you can use globbing patterns to include/exclude files)
    bundles.AddCss("/virtual-path/to/bundle.css")
        .Include("/physical-path/to/include.css")
        .Include("/another/physical-path/to/pattern*.css")
        .Exclude("/**/*.min.css");

    // defines a LESS bundle (you should include entry point files only)
    bundles.AddLess("/virtual-path/to/less-bundle.css")
        .Include("/physical-path/to/main.less");

    // defines an SCSS bundle (you should include entry point files only)
    bundles.AddSass("/virtual-path/to/scss-bundle.css")
        .Include("/physical-path/to/main.scss");

    // defines a JavaScript bundle
    bundles.AddJs("/virtual-path/to/bundle.js")
        .Include("/physical-path/to/*.js");
        //.EnableEs6ModuleBundling(); - uncomment this line if you want the included files to be treated as ES6 modules (include only entry point file(s) in this case!)
});

UseBundling adds a middleware to the ASP.NET Core request pipeline. You can consider it as a static files middleware, so you need to place it after the exception handler middleware but before the MVC middleware (and probably before authentication or authorization middlewares).

The behavior of the middleware can be customized by supplying a BundlingOptions instance to the UseBundling method. The possible settings are listed in the Reference section.

By default, the bundle URL paths will be prefixed with /bundles (this can be changed through the RequestPath option though), so the bundle registered to /virtual-path/to/bundle.css will be accessible at ~/bundles/virtual-path/to/bundle.css. However, you need to specify prefixed paths when you reference bundles in the Razor views! (Since even multiple bundling middlewares can be registered with different prefixes.)

It's also important to include the proper file extension (which corresponds to the outputted content) in the bundle path, otherwise the file won't be served. (Or you may mess with the options and supply another IContentTypeProvider, but that would be quite an unusual use case.)

By default, the include (and exclude) file paths are relative to the wwwroot folder (to be precise, to the root path of the file provider specified by the WebRootFileProvider property of the current IWebHostEnvironment). It's important to keep in mind that the file provider abstraction doesn't allow to access files located outside its root path! In such cases you need to create another PhysicalFileProvider with the right root path and pass that in by the SourceFileProvider option.

When specifying includes/excludes, you can use the ordinary globbing patterns supported by the .NET Core file providers.

Tip: instead of inefficiently adding excludes to remove some particular (like pre-minified) files, you may consider to implement an IFileBundleSourceFilter and add it as a global file filter.

3. Configure Razor views

In order to enable the bundling tag helpers you need to include the following lines in your _ViewImports.cshtml:

@using Karambolo.AspNetCore.Bundling.ViewHelpers
@addTagHelper *, Karambolo.AspNetCore.Bundling

4. Reference bundles in Razor views

Bundles can be referenced by tag helpers and static helper methods as well:

<!DOCTYPE html>
<html>
<head>
    @* [...] *@

    @* references stylesheet bundle using tag helper *@
    <link rel="stylesheet" href="~/bundles/virtual-path/to/bundle.css" />

    @* references stylesheet bundle using static helper *@
    @await Styles.RenderAsync("~/bundles/virtual-path/to/less-bundle.css")
</head>

<body>
    @* [...] *@

    @* references script bundle using tag helper *@
    <script src="~/bundles/virtual-path/to/bundle.js"></script>

    @* references script bundle using static helper *@
    @await Scripts.RenderAsync("~/bundles/virtual-path/to/bundle.js")
</body>
</html>

Design-time mode

Starting with version 2.0, it's possible to pre-build bundles at design-time. This is similar to how webpack or Mads Kristensen's BundlerMinifer works.

Just like in the case of run-time bundling, install the required NuGet packages first. On top of that you need to make sure that the core library is referenced as well:

dotnet add package Karambolo.AspNetCore.Bundling

(This package contains some files which are necessary to extend the build process and make the design-time method work.)

Prior to version 3.0 the step above automatically enabled the .NET Core CLI extension dotnet bundle by adding the necessary DotNetCliToolReference to your project. However, DotNetCliToolReference is more or less obsolete now, so version 3.0 switches to the newer approach introduced in NET Core 2.1. Thus, from version 3.0 on, you also need to install the .Net Core CLI extension manually. In return, you have multiple options to choose from:

  • You can make the tool globally available on your development machine.

    dotnet tool install -g dotnet-bundlingtools
    
  • You can install the tool into a specific directory.

    dotnet tool install --tool-path .tools dotnet-bundlingtools
    
  • You can make the tool available in your project only. (Please note that Local Tools are available since .NET Core 3 only.)

    dotnet new tool-manifest
    dotnet tool install dotnet-bundlingtools
    

After installing the necessary components, check if everything has been set up correctly: issue the dotnet bundle --version command in your project folder.

1. Define bundles

First you need to describe your bundles, which can be done in two ways currently. (These methods are not exclusive, you can even specify multiple configurations.)

1.a. Defining bundles by configuration file

You may define your bundles by placing a bundleconfig.json file in the root folder of your project. Originally, this format was established by Mads Kristensen's BundlerMinifier library but it is supported here as well. For details, please refer to the original documentation.

1.b. Defining bundles by code

In many cases configuration files are sufficient to define your bundles, but there are some features and settings which are not accessible using this approach. When you need full control over configuration, you have the option to specify it by code. All you need to do is create a class (with a default constructor) inheriting from DesignTimeBundlingConfiguration in your ASP.NET Core application:

public class MyBundles : DesignTimeBundlingConfiguration
{
    public MyBundles() { }

    // this property should return an enumeration of the used modules
    public override IEnumerable<IBundlingModule> Modules => base.Modules // CSS and JavaScript modules are already added by the base class
        .Append(new NUglifyBundlingModule()) // or .Append(new WebMarkupMinBundlingModule()) - whichever minifier you prefer
        .Append(new LessBundlingModule()) // to enable LESS support
        .Append(new SassBundlingModule()) // to enable SASS/SCSS support
        .Append(new EcmaScriptBundlingModule()); // to enable support for ES6 modules

    // in this method you can define your bundles using fluent API
    public override void Configure(BundleCollectionConfigurer bundles)
    {
        // defines a CSS bundle (you can use globbing patterns to include/exclude files)
        bundles.AddCss("/virtual-path/to/bundle.css")
            .Include("/physical-path/to/include.css")
            .Include("/another/physical-path/to/pattern*.css")
            .Exclude("/**/*.min.css");

        // defines a LESS bundle (you should include entry point files only)
        bundles.AddLess("/virtual-path/to/less-bundle.css")
            .Include("/physical-path/to/main.less");

        // defines an SCSS bundle (you should include entry point files only)
        bundles.AddSass("/virtual-path/to/scss-bundle.css")
            .Include("/physical-path/to/main.scss");

        // defines a JavaScript bundle
        bundles.AddJs("/virtual-path/to/bundle.js")
            .Include("/physical-path/to/*.js");
        //.EnableEs6ModuleBundling(); - uncomment this line if you want the included files to be treated as ES6 modules (include only entry point file(s) in this case!)
    }
}

When subclassing the abstract DesignTimeBundlingConfiguration class, you have to provide an implementation for the Configure method as shown in the example.

You usually need modules other than the core ones (CSS, JavaScript). If so, these modules need to be specified by overriding the Modules property.

There are additional properties which you can override to tweak global settings. For details, see the Bundle settings reference.

2. Produce bundles

Depending on your workflow, you have the following three options to process the configuration(s) and create the specified bundles:

2.a. Producing bundles manually

Execute the dotnet bundle command in your project folder and that's it.

By default, the CLI tool

  • checks for a configuration file (bundleconfig.json in the project folder) and
  • looks for code configuration in your application as well.

To be able to do the latter, the tool has to build your project first. If you don't use code configuration, you may rather use the dotnet bundle --sources ConfigFile command. This way, the tool skips building your application.

2.b. Updating bundles on build

You can easily setup your application to automatically update your bundles when you build it. Just insert these several lines under the root element (Project) of your project (csproj) file:

<PropertyGroup>
  <BundleOnBuild>true</BundleOnBuild>
</PropertyGroup>

When (re)building your project the next time, you should see the processed bundle configuration(s) in the build output.

Actually, no magic happens under the hood, just the CLI tool is invoked as a part of the build process. Because of that, you can supply the same options as if you executed it manually, you just need to use MSBuild properties:

MSBuild property CLI tool option
BundlingConfigSources --sources
BundlingConfigFile --config-file
BundlingMode --mode
2.c. Updating bundles on change of input files

This use case is not supported out-of-the-box currently, but you can make it work by the help of another CLI tool: dotnet watch.

Web assets are not monitored by default, so you need to add something like this to your project file first:

<ItemGroup>
  <Watch Include="wwwroot\**\*" Exclude="wwwroot\bundles\**\*;$(DefaultExcludes)"  />
</ItemGroup>

(For the exact configuration and capabilities of the watch tool, please refer to its official documentation.)

Then you can start monitoring by issuing the dotnet watch bundle --no-build command in the project folder.

Reference

a. Bundling middleware settings

The behavior of the bundling middleware can be tweaked by passing a BundlingOptions instance to the UseBundling method.

Description Default value
SourceFileProvider The file provider to use to access input files. IWebHostEnvironment.​WebRootFileProvider
CaseSensitiveSourceFilePaths Specifies if paths to input files should be treated as case-sensitive. false when SourceFileProvider abstracts a physical file system on Windows, otherwise true
StaticFilesRequestPath The path prefix to use when doing URL rebasing of other referenced web assets such as images, fonts, etc. none
RequestPath The path prefix to add to bundle URLs. It may be empty but that is not recommended as in that case identification of non-bundle requests requires some additional steps. "/bundles"
ContentTypeProvider Used to map files to content-types.
DefaultContentType The default content type for a request if ContentTypeProvider cannot determine one. none
ServeUnknownFileTypes Specifies if files of unrecognized content-type should be served. false
OnPrepareResponse This can be used to add or change the response headers.

b. Bundle settings

Bundle settings can be configured on multiple levels: globally, per bundle type, per bundle and per bundle item.

Settings made on a higher (more general) level is effective until it's overridden on a lower (more detailed) level. Technically, this means if a property is set to null, the corresponding setting value will be inherited from the higher level (if any). If it's set to a non-null value, the setting will be effective on the current and lower levels.

The configuration levels from high to low:

  1. Global settings

    • In run-time mode, these settings can be configured when registering services using the AddBundling method. You may tweak them by a configuration delegate passed in to the mentioned method. Some of them can be specified using fluent API, as well.

    • In design-time mode, you configure these settings by overriding the corresponding properties of the DesignTimeBundlingConfiguration class.

  2. Per bundle type settings

    • In run-time mode, these settings can be set also using configuration delegates when calling the AddCss, AddJs, etc. extensions methods on the builder returned by AddBundling.

    • In design-time mode, the configuration delegates can be passed to the constructors of modules when overriding the Modules property of the DesignTimeBundlingConfiguration class.

  3. Per bundle settings

    If you need more detailed control, you can specify settings for a single bundle using fluent API when defining them in UseBundling / DesignTimeBundlingConfiguration.Configure.

  4. Per bundle item settings

    There are some settings which can even be tweaked for items of bundles. These can be set by the optional parameters of the Include method available on the builder returned by AddCss, AddJs, etc.

Overview of settings
Description Default value Global Per type Per bundle Per item
EnableMinification Enables minification globally. If set to true, minification transformations will be added to the pipeline by default. false X
EnableChangeDetection Enables change detection of the source files. On change the cache for the involved bundles will be invalidated. false X
EnableCacheBusting Enables cache busting. If set to true, a version part will be added to the include URLs. (This global setting can be overrided for individual includes. Look for the bundling-add-version attribute or the addVersion parameter of the tag helper or static helper methods respectively.) false when IWebHostEnvironment.​EnvironmentName is equal to "Development", otherwise true X
EnableCacheHeader Enables client-side caching. If set to true, the Cache-Control HTTP header will be sent automatically. false X
CacheHeaderMaxAge Specifies the max-age value the Cache-Control HTTP header. undefined X
EnableSourceIncludes Enables including of source files instead of the actual bundled output. This is useful during development, however it's only possible when the bundle has no substantial transformations (such as pre-processing). false X X X
SourceItemToUrlMapper Used to map source items to URLs when rendering source includes. a default mapper which is able to determine URLs of files located within the root directory of IWebHostEnvironment.​WebRootFileProvider X X X
StaticFileUrlToFileMapper Used to map URLs to file provider files when file versions for pre-bundled or non-bundle files need to be computed. You only need to consider this option if you want cache busting for such files and those are not accessible at the standard location (e.g. you use some prefix for your static files). a default mapper which maps local URLs to files within IWebHostEnvironment. WebRootFileProvider. X
Builder The object responsible to produce the output of the bundle. X X X
FileFilters Objects that filters or sorts the input file list provided by file sources. X X X
ItemTransforms Transformations that are applied to each input item. (This can even be set on item level.) X X X X
Transforms Transformations that are applied to the concatenated output of input item transformations. X X X
ConcatenationToken The string to use to concatenate the outputs of input item transformations. "\n" for Css outputs
";\n" for Js outputs
X X
CacheOptions Options for bundle output caching. cache with no expiration X
DependsOnParams Declares that the query string is relevant for caching as the bundle use it to provide its output. false X
OutputEncoding Encoding of the output. UTF-8 X
InputEncoding Encoding of the input. auto-detect, fallback to UTF-8 X

Samples

If you're new to the library or want to learn more about its capabilities, I suggest looking around here where you find some simple demo applications like:

VueDemo

This sample shows how you can setup a component-based Vue.js application. (This one uses vanilla JavaScript and doesn't use ES6 modules but it can be easily re-configured by examining the setup of the TypeScriptDemo app.)

DynamicBundle

Check out this demo to get an idea how dynamic parameterized bundles works and what they can be used for.

Any feedback appreciated, contributions are welcome!

bundling's People

Contributors

adams85 avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bundling's Issues

Using CDN

Do we have a possibility use CDN?

How to apply transforms to a Bundle like we used to do in Asp.Net MVC 4?

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.

Tree shaking in EcmaScript

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.

JS: Multiple mobile versions give syntax errors after bundeling.

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.
image
image

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); } ); }

.Net Core 3 issues

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

EcmaScript - NullReferenceException when variable is not declared

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)

Question: How to handle client side caching

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:

  • Using asp-append-version="true"
  • Checking out the example projects

Are there plans to update bundling tools to target .NET 7?

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

Vuejs

It is possible to use files with .vue extension ?

Hot good it works with vuejs.react.angular frameworks ?

Render individual includes

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?

Cannot access node_modules folder

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!

asp-append-version tag doesn't seem to work with bundled script

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>

<script src="/Scripts/clients/dashboard/dashboardPage.js?v=8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U"></script>`

Issue when script file has been modified outside of Visual studio

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.