如何使用 ASP.NET WebApi 项目配置 Grunt?

How to configure Grunt with ASP.NET WebApi Project?

我是 grunt 的新手,我想在我当前的 Asp.Net WebApi 单页应用程序中使用它。为此,我想知道我们如何使用 ASP.NET Project..

配置 Grunt

我正在使用 Visual Studio 2013

尝试说明您的问题。

Google 了解大量关于 VS 2013/2015 中 Grunt 的文章。

尝试使用这些中的任何东西,如果您仍然遇到问题,将指出您的问题。

安装 Grunt

solution > right click > add > new item > npm Configuration file > paste following code > save > be patient until it installs

{
    "version": "1.0.0",
    "name": "asp.net",
    "private": true,
    "devDependencies": {
    "grunt": "1.0.1",
    "grunt-contrib-uglify": "1.0.1",
    "grunt-contrib-watch": "1.0.0",
    "bower": "1.7.9"
  }
}


配置 Grunt

solution > right click > add > new item > Grunt Configuration file > paste following code > save

module.exports = function (grunt) {

    //load whatever you need here
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');

    //Task configuration is specified in your Gruntfile via this method
    grunt.initConfig({
        uglify: {
            my_target: {
                files: {
                    'wwwroot/app.js': ['scripts/app.js', 'scripts/**/*,']
                }
            }
        },
        watch: {
            script:{
                files: ['scripts/**/*,'],
                tasks: ['uglify']
            }

        }
    });
    //register your tasks here(taskName,taskList)
    grunt.task.registerTask('task-minified', ['uglify', 'watch'])

};


测试 Grunt

View > Other Windows > Task Runner Explorer