zoukankan      html  css  js  c++  java
  • 自动编译CoffeeScript的Gruntfile.js

    比如把coffee文件写在coffee/controller/文件夹下,新建js/controller文件夹,使用grunt运行项目,将自动编译coffee到相应的js文件夹下。

    module.exports = function(grunt) {
      // 项目配置信息.
      grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jshint: {
          options : {
            jshintrc: '.jshintrc',
            // eqeqeq: true,
            // tradiling: true,
            ignores: ['node_modules/**/*.js']
          },
          all: ['**/*.js']
        },
        coffee:{
          compile: {
            options: {
              sourceMap: false,
              bare: true
            },
            files: [{
              expand: true,
              cwd: "coffee/",
              src: '**/*.coffee',
              dest: 'js/',
              ext: '.js'
            }]
          }
        },
        watch: {
          coffee: {
            files: ['**/*.coffee'],
            tasks: ['coffee:compile']
          // },
          // js: {
          //   files: ['**/*.js'],
          //   tasks: ['jshint'],
          //   options: {
          //     livereload: true
          //   }
          }
        },
        nodemon: {
          dev: {
            script: 'bin/www',
            options: {
              args: [],
              ignoredFiles: [],
              watchedExtensions: ['js'],
              watchedFolders: ['./'],
              debug: true,
              delayTime: 1,
              env: {
                PORT: 3000
              },
              cwd: __dirname
            }
          }
        },
        concurrent: {
          tasks: ['watch','nodemon'],
          options: {
            logConcurrentOutput: true
          }
        }
      });
      // 加载"uglify"插件..
      grunt.loadNpmTasks('grunt-contrib-watch');
      grunt.loadNpmTasks('grunt-contrib-coffee');
      grunt.loadNpmTasks('grunt-contrib-jshint');
      grunt.loadNpmTasks('grunt-nodemon');
      grunt.loadNpmTasks('grunt-concurrent');
      //grunt.loadNpmTasks('grunt-ssh');
    
      grunt.option('force', true);
    
      // 注册默认任务.
      grunt.registerTask('default', ['concurrent']);
    };
  • 相关阅读:
    三级联动(在YII框架中)
    用composer安装Yii
    在apache中设置访问目录后进入的默认页面为index.php
    php mb_convert_encoding的使用
    采集数据和memchche的存储使用,分页展示
    php操作Memcache
    前端页面卡顿?或是DOM操作惹的祸,需优化代码
    windows mongodb 安装
    浅谈WebSocket
    使用Spring MVC HandlerExceptionResolver处理异常
  • 原文地址:https://www.cnblogs.com/ishell/p/4219002.html
Copyright © 2011-2022 走看看