Open mattspeterson opened 2 years ago
It would be great,
I tried to bundle without minification, but without success.
2 remarks :
<environment include="Development">
<script asp-src-include="/lib/**/*.js"></script>
</environment>
<environment exclude="Development">
<script src="/js/bundle.js"></script>
</environment>
"outputFileName": "wwwroot/js/app.js",
"inputFiles": [
"Scripts/lib/lib1.js",
"Scripts/lib/lib2.js",
],
"minify": {
"enabled": false
}
}
And minified with weboptimizer :
if (CurrentEnvironment.IsDevelopment())
{
services.AddWebOptimizer(minifyCss : false, minifyJavaScript : false);
}
else
{
services.AddWebOptimizer();
}
That's a little bit tricky but it works
Running into this same problem! There has got to be a better way to register the bundles in one place and then simply list out the individual file references on the page when in development mode. What am I missing?
I ran into this same issue. The solution for me was that I forgot to add the Tag Helpers to the _ViewImports.cshtml file. Once I did that, it automatically disabled bundling when running locally and re-enabled bundling once deployed.
When using ASP.NET's previous built-in bundling/minification capabilities, you could register a bundle, reference that in a view (using
@Scripts.Render
), and it would render the correct script tags depending on the environment -- the un-bundled, un-minified script files that comprise the bundle in development, and the fully-bundled/minified version in production.Is there any way to accomplish this using WebOptimizer? It seems that you can selectively enable bundling and minification in the pipeline (by checking
env.IsDevelopment()
as shown in the README), but how can you use one<script>
tag in your view for both environments? It seems the only way is to do something like this:...but then you are essentially defining your bundle in two places. Let me know if there is an option I'm missing. Thanks!