madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Not minifying on build #167

Open ygoe opened 8 years ago

ygoe commented 8 years ago

Installed product versions

CSS and JavaScript files are not minified at build time. Bundling not tested. I'd expect this to happen during building on a build server, so I don't have to check the .min.* files into version control.

Steps to recreate

  1. Add a .css file to the project, make sure there's no .min.css file for it
  2. Add a non-empty .js file to the project, make sure there's no .min.js file for it
  3. Build the project in Visual Studio (Rebuild command)

    Current behavior

No .min.css and .min.js file there after build.

Expected behavior

.min.css and .min.js file should have been created just like when I edit and save the .css/.js file in the Visual Studio editor.

Additional information

There's also a screenshot of a context menu with "Enable bundle on build" in the main README, but I don't see this menu item anywhere. The README has a contradictory screenshot further down that shows other commands, which is what I see here.

I'm evaluating removing any trace of gulp and bower in my ASP.NET Core project because I don't understand what it is and how it works. This extension seems to provide the same functionality and works in a much more predictable way.

ghost commented 8 years ago

I am seeing this to, and I wasted about 4 hours trying to figure out why. First off, the message at the bottom of Visual Studio is pretty much ignored, and you'd never expect to see an error message there on a file save. The message tells you to look at the "Error List", which we NEVER use, as it is so full of junk messages that it is useless.

In my case, the issue appears to be the fact that I define a variable on the main HTML page, and the minifier is complaining that I am trying to set a variable in "Strict-mode", without declaring the variable in the .js file. The minifier used to read the JSHint information, but apparently this is no longer occurring.

For example "/* globals fields: true */" is no longer working and setting that variable is now causing:

(Bundler & Minifier) Strict-mode does not allow assignment to undefined variables: fields

Is there a work-around for this?

sanjeev40084 commented 8 years ago

@ygoe @Kaelum see if this helps: https://github.com/madskristensen/BundlerMinifier/issues/154#issuecomment-232708088

ghost commented 8 years ago

@sanjeev40084: That issue does not apply to the issue that I have observed. The minifier is trying to create a minified version, but once it encounters this invalid error condition, it stops. If the issue that is causing this invalid error condition to be flagged, is corrected, it will work. As a test to prove this, I commented out the "use strict" statements, and it worked.

For your issue, have you watched the "status" line at the bottom of the VS window? It may contain information for your issue, and is very easy to overlook (took me 4 hours to see it).

P.S. I removed all minification statements to use the built-in minify on save functionality.

Gamewriter commented 8 years ago

We right-clicked on budleconfig.json in Solution Explorer and in the Budler & Minifier submenu we checked "Enable bundle on build..." It would not stay checked. A message at the bottom of window the said that a NuGet package wasn't being loaded. We found that NuGet wasn't loading BuildBundlerMinifier, so we had to load it manually, and set the checkmark again. Now it will minify on build.

BTW, we stopped using Gulp months ago.

capture

thewoody commented 7 years ago

We've just removed Gulp from our build and using the Bundler & Minifier and Compiler and both the bundleconfig.json and compilerconfig.json have "Enable bundle on build" and "Enable compile on build" ticked, but when I build or rebuild the solution, none of the output files are generated. If I right-click the json's and either "Update bundles" or "Re-compile all files" then the files are generated. I did read that these packages would not compile on build due to bootstrap and would only compile on build if there are corresponding css and js output files already in the solution?! ... Ideally I don't want to have to incl. all the files in GIT when merging my code up. Any help would be really useful. Thank you!

braegelno5 commented 7 years ago

You are in VS201x, or VSCode?

thewoody commented 7 years ago

OK, it was user error. I didn't include the packages in the build config, although the packages were installed and referenced .... We've tested it and works a treat. Lesson learned I think!