2015-05-20 21 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... 
    
相關問題