在我的 GruntFile.js
我有 bower
任务:
bower: {
dev: {
dest: 'lib'// will get stuff from 'bower_components' to 'lib' folder
}
},
所以当我这样做时:
grunt bower
它转换 一些 来自 bower_component
的东西文件夹到 lib
.. 所以我最终得到了如下文件:angular.js
在/lib
.但它不复制
"angular.min.js"
,位于 bower_component
.问:如何配置 grunt bower 任务来复制缩小的文件 v?
我还不想将缩小/丑化任务放到 GruntFile 中。由于这些文件已经在
bower_components
中缩小了.
最佳答案
您应该使用 bower 任务来下载 bower 组件并添加复制任务以根据需要移动文件。
安装 grunt-contrib-copy
npm install grunt-contrib-copy --save-dev
并在您的 grunt 文件中使用它:
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* more tasks... */
copy: {
main: {
files: [
// includes files within path
{expand: true, src: ['path/*'], dest: 'dest/', filter: 'isFile'},
// includes files within path and its sub-directories
{expand: true, src: ['path/**'], dest: 'dest/'},
// makes all src relative to cwd
{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'},
// flattens results to a single level
{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'},
],
},
}
});
您可以将其配置为仅复制
**.min.js
的内容。文件。
关于gruntjs - 使 grunt bower 从 "bower_components"获得缩小版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29018610/