Javascript 如何告诉Lineman将所有文件从/dist复制到其他目录?
当我运行lineman build时,它会在/dist目录中生成所有缩小的CSS和JS。我不知道如何让它将这些缩小的文件复制到另一个目录,即路径-../lib/app/Public处的公共目录 我的Lineman配置文件如下所示Javascript 如何告诉Lineman将所有文件从/dist复制到其他目录?,javascript,gruntjs,grunt-contrib-copy,linemanjs,Javascript,Gruntjs,Grunt Contrib Copy,Linemanjs,当我运行lineman build时,它会在/dist目录中生成所有缩小的CSS和JS。我不知道如何让它将这些缩小的文件复制到另一个目录,即路径-../lib/app/Public处的公共目录 我的Lineman配置文件如下所示 # Exports an object that defines # all of the configuration needed by the projects' # depended-on grunt tasks. # # You can familiariz
# 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 %>"
}
},
})
我知道Lineman中有一个copy:dist default任务,但不确定它是如何工作的,无法从文档中正确理解它,在Lineman的帮助下,我解决了这个问题: 编写自定义任务tasks/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的输出,请参见下面的内容。在监视文件更改时,它与此类似,我们运行lineman build:
lineman run
Running "common" task
...
Running "copy:dl-dev-copy" (copy) task
Created 6 directories, copied 23 files
...
Running "watch" task
Waiting...