Grunt,指南针,基金会(foundationpress wordpress主题)

时间:2014-10-16 22:01:11

标签: javascript wordpress compiler-construction gruntjs zurb-foundation

我希望使用grunt将我的javascript从js / custom / *。js编译成app.js。我想拥有它,以便我修改/写入的任何脚本都在我的localhost上编译和更新。

我有正确的编译,虽然grunt我只想在(js / custom / * .js)中使用我的脚本快速完成同样的事情。

不确定这是通过罗盘还是咕噜声完成,只需要一个正确方向的点。谢谢。

    module.exports = function(grunt) {
    var jsApp = [
    'js/app.js',
    'js/_*.js'
  ];

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      options: {
        includePaths: ['bower_components/foundation/scss']
      },
      dist: {
        options: {
          outputStyle: 'expand'
        },
        files: {
          'css/app.css': 'scss/app.scss'
        }        
      }
    },

    copy: {
      scripts: {
        expand: true,
        cwd: 'bower_components/',
        src: '**/*.js',
        dest: 'js'
      },

      maps: {
        expand: true,
        cwd: 'bower_components/',
        src: '**/*.map',
        dest: 'js'
      }
    },

    uglify: {
      dist: {
        files: {
          'js/modernizr/modernizr.min.js': ['js/modernizr/modernizr.js']
        }
      }
    },

    concat: {
      options: {

        separator: ';'
      },
    dist: {  
        src: [
          'js/foundation/js/foundation.min.js',
          'js/custom/*.js'
        ],

        dest: 'js/app.js'
      }

    },

    watch: {
      grunt: { files: ['Gruntfile.js','js/app.js'] },

      sass: {
        files: 'scss/**/*.scss',
        tasks: ['sass']
      },

    }
  });

  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.registerTask('build', ['sass']);
  grunt.registerTask('default', ['copy', 'uglify', 'concat', 'watch']);
}

1 个答案:

答案 0 :(得分:1)

将concat任务添加到手表中,并且应该修复它。

watch: {
      grunt: { files: ['Gruntfile.js'] },

      sass: {
        files: 'scss/**/*.scss',
        tasks: ['sass']
      },
      concat: {
        files: ['js/custom/*.js'],
        tasks: ['concat']

      }
}