Grunt、Compass、Foundation(foundationpress wordpress 主题)

问题描述 投票:0回答:1

我希望使用 grunt 将我的 javascript 从 js/custom/*.js 编译到 app.js 中。我希望拥有它,以便我修改/编写的任何脚本都可以在我的本地主机上编译和更新。

我的 sass 编译正确,虽然 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']);
}
javascript wordpress gruntjs zurb-foundation
1个回答
1
投票

将 concat 任务添加到您的手表中,这样就可以解决问题。

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

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

      }
}
© www.soinside.com 2019 - 2024. All rights reserved.