ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
777 stars 114 forks source link

Bundling any ".min.js" file results in 404 #132

Open BobbyCannon opened 4 years ago

BobbyCannon commented 4 years ago

I'll work on getting an example repo but I wanted to go ahead and drop an issue while it's fresh on my mind. I went to update an older app and I noticed that my JS started to result in 404. After some debugging I noticed that if any js that was already minified was added via AddJavaScriptBundle it would cause the bundle to 404.

Ex. for existing min files. Jquery, Vue, Charts.js.

BobbyCannon commented 4 years ago

I have found that 3.0.250 does not have this issue. I have rolled back to that version for now. Hopefully I'll have some time free soon to do some further research.

BobbyCannon commented 4 years ago

Here are the libraries I'm using. It seems only the ".min.js" are causing the issues

"/lib/vue/vue.min.js", "/lib/vue-resource/vue-resource.min.js", "/js/vue-date.js", "/js/vue-progressbar.js", "/js/vue-resource-progressbar-interceptor.es5.js", "/js/vue-substring.js", "/js/vuelidate.min.js", "/js/validators.min.js", "/lib/jquery/jquery.min.js", "/js/jquery.FieldSelection.js", "/lib/underscore/underscore.js", "/js/chart.min.js", "/lib/signalr/signalr.min.js", "/lib/moment/moment.js", "/lib/toastr/toastr.min.js"

You may ask. Well Bob, if only the .min.js files are the problem then just reference the "non" min versions. Well some of the libraries do not have the non-minified version.

BobbyCannon commented 4 years ago

found the issue. Turns out your first file in the

pipeline.AddJavaScriptBundle( "/js/bundle.js", new CodeSettings { MinifyCode = false, }, "/js/empty.js", <- this first entry must not end with "min.js", if so then you'll always get a 404 "/lib/vue/vue.min.js", ...