gpt4 book ai didi

syntax - 如何在 Grunt.js 中指定目标文件夹路径与 Gruntfile.js 相同?

转载 作者:行者123 更新时间:2023-12-01 23:57:05 25 4
gpt4 key购买 nike

问题:我想配置一个名为 Grunt Markdown 的 grunt 模块,并且部分配置要求我提供目标文件的路径。我不知道如何告诉 Grunt 我希望目标文件输出到与 Gruntfile.js 文件相同的级别。

信息:我相信文件路径是相对于 Gruntfile.js 的,我查看了 the documentation帮助我理解语法。您将在下面找到我的 Gruntfile.js 的工作示例

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: ['js/jquery-1.7.1.min.js','js/jquery.ui.js','js/jquery.iosslider.js','js/jquery.isotope.min.js','js/jquery-css-transform.js','js/jquery-rotate.js','js/browserdetect.js','js/mainactions.js','js/min/gsapi.min.js','js/blurobjs.js','library/scripts/vallenato.js','js/soilsextension_custom.js'],
dest: 'js/min/master.min.js'
}
},
sass: { // Task
dist: { // Target
options: { // Target options
style: 'compressed'
},
files: { // Dictionary of files
'css/main-child/main-child.css': 'css/main-child/main-child.scss', // 'destination': 'source'
'css/mobile-child/mobile-child.css': 'css/mobile-child/mobile-child.scss'
}
}
},
concat: {
options: {
separator: ' ',
},
dist: {
src: ['css/main-child/main-child.css', 'css/mobile-child/mobile-child.css'],
dest: 'css/master-child/master-child.css',
},
},
markdown:{
all:{
files:[
{
expand:true,
src:'md/*.md',
dest:
}
]
}
},
watch: {
scripts: {
files: ['js/*.js'],
tasks: ['uglify'],
options: {
livereload: true,
},
},
css: {
files: '**/*.scss',
tasks: ['sass','concat'],
options: {
livereload: true,
},

}
},

imagemin: { // Task
dynamic: { // Another target
files: [{
expand: true, // Enable dynamic expansion
cwd: 'images/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'dist/' // Destination path prefix
}]
}
}

});
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-markdown');


// Default task(s).
grunt.registerTask('default', ['uglify']);
grunt.registerTask('default', ['sass']);
grunt.registerTask('default', ['concat']);
grunt.registerTask('default', ['watch']);
grunt.registerTask('default', ['imagemin']);
grunt.registerTask('default', ['markdown']);

};

问题:告诉 Grunt 我的目标路径位于项目的根目录的必要语法是什么,这遵循什么语法规则(以便我以后可以在需要时引用它们)?

最佳答案

只需使用:

markdown: {
all: {
files:[
{
expand:true,
src: 'md/*.md',
dest: './'
}
]
}

关于syntax - 如何在 Grunt.js 中指定目标文件夹路径与 Gruntfile.js 相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23117683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com