首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >咕噜声:如何检测是否保存了文件以使我的js文件丑陋。

咕噜声:如何检测是否保存了文件以使我的js文件丑陋。
EN

Stack Overflow用户
提问于 2015-08-13 11:28:29
回答 1查看 126关注 0票数 1

我正在尝试检测是否保存了一些js来丑化我的js文件或我的css文件。

我在GruntFile.js中有以下代码:

代码语言:javascript
复制
/// <binding ProjectOpened='uglify' />
module.exports = function (grunt) {
    grunt.initConfig({

        uglify: {
            bundle: {
                files: { 'Scripts/boooo.min.js': 'Scripts/bootstrap.js' }
            }
        },
        watch: {
            js: {
                files: ['Scripts/**/*.js'],
                tasks: ['uglify']
            }
        }
    });

    // Next one would load plugins
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');


    // Here is where we would define our task
    grunt.registerTask('default', ['watch:js']);


};  

我的任务运行器资源管理器是:

我的包裹是:

代码语言:javascript
复制
{
  "name": "something",
  "version": "1.0.0",
  "description": "test",
  "main": "index.html",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-bower-task": "^0.4.0",
    "grunt-contrib-copy": "^0.8.0",
    "grunt-contrib-uglify": "^0.9.1",
    "grunt-contrib-watch": "^0.6.1",
    "install": "^0.1.8",
    "jshint-stylish": "^2.0.1",
    "npm": "^2.13.4"
  }
}

如何检测它是否被保存?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-20 14:53:29

代码语言:javascript
复制
module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            scripts: {
                files: ['scripts/**/*.js'],
                tasks: ['uglify']
            }
        },
        uglify: {
            my_target: {
                options: {
                    beautify: false
                },
                files: {
                    '/Scripts/app.min.js': ['scripts/**/*.js']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask('default', ['uglify:my_target', 'watch']);
};
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31986921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档