【发布时间】:2014-02-24 17:14:39
【问题描述】:
我正在使用 Bower 和 GruntJS。我认为 grunt-bowercopy 会在完成后删除 bower_components 文件夹,但这并没有发生。
grunt-bowercopy 可以在将文件复制到我想要的位置后删除 bower_components 文件夹吗?
这是我的文件夹设置:
->Project
->Themes
->Theme
->assets
->scripts
->styles
->tools
->build
->bower_components
->bower.json
->gruntfile.js
->package.json
这是我在 gruntfile.js 中运行 grunt-bowercopy 的方式
module.exports = function (grunt) {
// Loads the necessary tasks for this Grunt file.
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
bowercopy: {
options: {
clear: true
},
js: {
options: {
destPrefix: '../../Themes/Theme/assets/'
},
//The key is the destination file. The value is the file from the bower_components folder
//The files will be added to a scripts folder at the location: ../../themes/3MTheme/assets/scripts
//The key is the name of the folder that is copied into the /assets folder.
src : 'scripts'
},
css: {
options: {
destPrefix: '../../Themes/Theme/assets/'
},
src: 'styles'
}
}
// Custom task, executed via the command "grunt bowercopy"
grunt.registerTask('bower', ['bowercopy']);
};
【问题讨论】:
-
如果它在您构建项目后删除了 bower_components 文件夹,您将需要再次安装这些组件以进行下一次构建,对吗?为什么要删除该文件夹?它仅用于开发目的,不会进入 dist 文件夹。
-
@Sergey,我正在从共享服务器复制一些文件。这些文件可能偶尔会被其他人更新,我想确保我删除了那些最新的更新。
标签: javascript gruntjs bower