"Web Compiler" compile on save not working
Asked Answered
S

8

10

I am using web compiler but it will not compile my SASS structure unless I right-click on "compilerconfig.json" and select "Web-compiler" --> "Re-compile all files".

When I use the other methods to trigger compile...

  • When I save a SCSS-file (most important)
  • When I go to menu "Build" --> "Re-compile all files in solution"
  • When I use the short command Shift + Alt + Y

It will tell me "Compiled successfully" or "Done compiling", however files are not updated.

I am using Visual Studio 2015 v.3 and Web Compiler UPDATED 8/2/2016, VERSION 1.11.319.

Shall answered 2/9, 2016 at 8:6 Comment(0)
S
12

Found the answer in a forum. I just needed to remove some temp files and restart Visual Studio:

%localappdata%\temp\WebCompiler1.xx

Forum post: https://github.com/madskristensen/WebCompiler/issues/158

Hope this helps someone!

Shall answered 2/9, 2016 at 8:27 Comment(1)
See github.com/madskristensen/WebCompiler/issues/… for a related fix with more detail, especially if the above did not quite fix it for you.Albina
T
1

Sadly, the solution offered here did not work. Seems I'm not alone in this.

In case it helps anyone else, I found another workaround, which seems to offer an extra side benefit.

If you add a Razor view to your project (I named it JsHelper.cshtml and added it in \Views\Shared) and use the following for the contents (extra line breaks added to make it fit in the SO width)...

@model string
@{
  string ext = HttpContext.Current != null
               && HttpContext.Current.Request.Url.Host.Contains("localhost")
    ? ""
    : ".es5.min";
}
<script src="/Scripts/@Model@(ext).js" type="text/javascript"></script>

...then instead of adding script tags like this...

<script src="/Scripts/General.es5.min.js" type="text/javascript"></script>

...you can add this...

@Html.Partial("~/Views/Shared/JsHelper.cshtml", "General")

When you are running the web site in Visual Studio, the uncompiled version of the Javascript file will be used. When running anywhere else (eg on the production server), the .es5.min.js version will be used.

As publishing a web project involves building it, which will compile the .js files, you can be confident that the compiled and minified files that are published are up-to-date.

This has the side-benefit that when debugging your scripts in the browser, you have access to the full version of the .js file, instead of the compiled and minified version that you would get if you referenced them directly. As another breaking change that occurred in the latest version of Web Compiler is that they no longer produce .map.js files when compiling, this is a huge side benefit.

Hope this helps.

Tollhouse answered 14/6, 2017 at 18:4 Comment(0)
B
0

In troubleshooting this issue I've found that this extension has been "automatically" disabled at times. I'm sure this is not something I've done, but there may be a mechanism within Visual Studio that periodically disables extensions. Just another thing to check.

Billion answered 6/4, 2018 at 15:44 Comment(0)
L
0

after updating to VS 2017 Version 15.9.5 compile with save doesn't work for me. I can right click on scss files and compile but again nested css not compiled. It seems as if updating visual studio is the issue.

Alternatively you can uninstall web compiler and use compilesass,

you can download from here

Lotta answered 26/1, 2019 at 18:47 Comment(0)
B
0

If you recently installed a new Visual Studio, make sure to re-install the WebCompiler extension. Extensions > Manage Extensions

Bushnell answered 30/11, 2021 at 22:11 Comment(0)
S
0

This applies to VS2022, I don't know for other versions but it can be relevant too.

I had a project where css generation was working properly when clicking on "Re compile files" from projet or single file, but not automatically at build or save of .scss.

To have it working, the project must reference the following nuget package :

<ItemGroup>
    <PackageReference Include="BuildWebCompiler2022" Version="1.14.4" />
    ....
<ItemGroup>

Of course the exact version may depend of what's available when you will read this message.

You can also add it automatically by right-clicking on a .scss file, click on "Web compiler" menu, and click on "Enable compile at build", it will add the missing reference.

Saleh answered 2/3, 2022 at 8:23 Comment(0)
R
0

I just uninstalled the extension and package, removed all project files (.config and .scss) fully shut down all instances of VS 2022. Reinstalled everything making sure VS was fully loaded/unloaded between steps, added files back and compile on save is not working again. However, upon save the css file updated then I immediately got a BSOD. I realize I have gotten a couple of these since installing this extension a few days ago.

FYI... I tried this reinstall before and it didn't work. This time I made sure VS everything was uninstalled before reinstalling. Immediately after reinstalling the extension and before doing anything else I noticed there was a context menu option by right clicking the compilerconfig.json > Web Compiler that said something about removing from the compile process or something. It wasnt the typical "Enable compile on build...". Now that menu option is gone.

Referendum answered 3/11, 2022 at 14:45 Comment(0)
T
0

Sometimes, the Web Compiler extension isn't finished extracting its node_modules files if you just recently installed it.

Wait for 7z.exe process to end for about 10 minutes, you can confirm it via Task Manager. You will notice that the files in %LocalAppData%/Temp/WebCompiler1.x.x/node_modules are increasing.

Tangential answered 17/2, 2023 at 1:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.