Search code examples
visual-studio-2015web-essentials

Web Essentials 2015 WebEssentials-Settings.json File?


In Web Essentials 2013 you could include your Web Essentials settings in a .json file (aptly named WebEssentials-Settings.json) at the solution level to ensure that everyone working on the project was using the same settings. One of the nicer aspects of this is that it could be stored in version control, and you could enforce things for your team like automatically running JSHint on build.

Is there a way to achieve this behavior (common settings definitions stored in source control) in VS 2015 with Web Essentials 2015?

At least as of the time of writing this, Web Essentials seems to have dropped support for the .weignore file (See Web Essentials - General Features and toggle the version dropdown between 2013 and 2015)... I'm hoping the settings file didn't disappear as well.


Solution

  • WebEssentials Solution Settings:

    It appears the file name and structure has changed in WE 2015 (which makes sense seeing as how the feature set has changed).

    You can generate a WebEssentials2015-Settings.json file by navigating to:

    "Web Essentials > Create solution settings" in Visual Studio 2015.

    Create solution settings

    WebEssentials2015-Settings.json

    Web Compiler Configuration:

    The Web Compiler settings appear to have moved to their own files called compilerconfig.json and compilerconfig.json.defaults that get generated at the project level.

    The Web Compiler configuration is documented on the Web Compiler extension page and allows you to specify different settings on a per file basis.

    From the extension page:

    compilerconfig.json

    The extension adds a compilerconfig.json file at the root of the project which is used to configure all compilation.

    Here's an example of what that file looks like:

    [ { "outputFile": "output/site.css", "inputFile": "input/site.less", "minify": { "enabled": true }, "includeInProject": true, "options":{ "sourceMap": false } }, { "outputFile": "output/scss.css", "inputFile": "input/scss.scss", "minify": { "enabled": true }, "includeInProject": true, "options":{ "sourceMap": true } } ]

    Default values for compilerconfig.json can be found in the compilerconfig.json.defaults file in the same location.

    CompileOnBuild Support:

    Compile on build support is enabled via the NuGet package "BuildWebCompiler". If you right click on the web project in the Solution Explorer and choose "Web Compiler > Enable compile on build..." from the context menu, this package is installed to the project and LESS, Sass, JSX, and CoffeeScript transpilation supported by the Web Compiler extension will occur on build.

    Enable compile on build...

    (Side note: this threw an exception for me when I tried to enable it through the context menu, but "CompileOnBuild" worked when I installed the "BuildWebCompiler" NuGet package through the NuGet Package Gallery).