2015-05-20 17 views
0

当我运行lineman build时,它会在/dist目录中生成所有缩小的CSS和JS。我不知道如何使它复制这些缩小文件到不同的目录(我的公共目录在路径 - ../lib/app/public)。如何让Lineman将/ dist中的所有文件复制到不同的目录中?

我的Lineman配置文件看起来像这样。

# Exports an object that defines 
# all of the configuration needed by the projects' 
# depended-on grunt tasks. 
# 
# You can familiarize yourself with all of Lineman's defaults by checking out the parent file: 
# https://github.com/testdouble/lineman/blob/master/config/application.coffee 
# 

module.exports = require(process.env['LINEMAN_MAIN']).config.extend('application', { 
    removeTasks: 
    common: [ "webfonts:dev", "images:dev"] 
    dist: ["images:dist", "webfonts:dist", "pages:dist"] 

    server: 
    apiProxy: 
     enabled: true 
     host: 'localhost' 
     port: 4567 

    # enableSass: true 

    # configure lineman to load additional angular related npm tasks 
    loadNpmTasks: [ "grunt-ngmin"] 

    # task override configuration 
    prependTasks: 
    dist: ["ngmin"]   # ngmin should run in dist only 

    watch: 
    scripts: 
     files: ["generated/**"], 
     tasks: ['copy:dev'] 

    copy: 
    dev: 
     files: [expand: true, cwd: 'generated', src: ['css/**', 'js/**', '!**/spec.js', 
       '!**/*.less*', '!**/*.coffee*', '!**/*.*.map'], dest: '../lib/app/public' ] 

    # configuration for grunt-ngmin, this happens _after_ concat once, which is the ngmin ideal :) 
    ngmin: { 
    js: { 
     src: "<%= files.js.concatenated %>", 
     dest: "<%= files.js.concatenated %>" 
    } 
    }, 
}) 

我知道有在架线工一copy:dist默认的任务,但不知道它是如何工作的,并不能很好地从文档的http://linemanjs.com/

回答

0

理解我解决了这个问题,用架线工的帮助:

  • 写了一个定制任务,任务/ DL-DEV-copy.js,要复制的文件:

    module.exports = function(grunt) { 
        return grunt.registerTask('dl-dev-copy', 'Copy UI artifacts to wildfly deployment folder', ['copy:dl-dev-copy']); 
    }; 
    
  • 更新了的application.js文件(关键部分是很重要的,我只能在架线工人们之后的数字出来帮了我):

    loadNpmTasks: lineman.config.application.loadNpmTasks.concat('grunt-contrib-copy'), 
        copy: { 
         'dl-dev-copy': { 
         files: [{ 
          expand: true, 
          cwd: 'generated/', 
          src: ['**'], 
          dest: '../../../target/iq/' 
         }] 
        } 
    }, 
    watch: { 
        target: { 
         "files": ["app/**/*", "spec/**/*", 'spec-e2e/**/*'], 
         "tasks": 'dl-dev-copy' 
        } 
    }, 
    appendTasks: { 
        common: ["dl-dev-copy"] 
    } 
    
  • 见下面的输出前锋运行的(它类似于当一个文件正在被监控的变化,我们我跑前锋打造):

    lineman run 
    Running "common" task 
    ...  
    Running "copy:dl-dev-copy" (copy) task 
    Created 6 directories, copied 23 files 
    ... 
    Running "watch" task 
    Waiting... 
    
相关问题