How to use npm with ASP.NET Core

前端 未结 10 2032
孤街浪徒
孤街浪徒 2020-11-29 15:05

I\'m using npm to manage the jQuery, Bootstrap, Font Awesome and similar client libraries I need for my ASP.NET Core application.

The approach that worked for me sta

10条回答
  •  被撕碎了的回忆
    2020-11-29 15:57

    Install the Bundler and Minifier into Visual Studio Extensions

    Then you create a bundleconfig.json and enter the following like :

    // Configure bundling and minification for the project.
    // More info at https://go.microsoft.com/fwlink/?LinkId=808241
    [
     {
        "outputFileName": "wwwroot/js/jquery.min.js",
        "inputFiles": [
          "node_modules/jquery/dist/jquery.js"
        ],
        // Optionally specify minification options
        "minify": {
          "enabled": true,
          "renameLocals": false
        },
        // Optionally generate .map file
        "sourceMap": false
      }
    ]
    

    So the bundler and minifier (gulp based) has access to the source files (which should be excluded from Visual Studio and also excluded from GIT) and puts them into the wwwroot as specified

    only side effect every time you save it will run this (but you can set it to run it manually)

提交回复
热议问题