【问题标题】:Make grunt bower get minified version from "bower_components"让 grunt bower 从“bower_components”获取缩小版本
【发布时间】:2015-03-12 19:27:45
【问题描述】:

在我的GruntFile.js 我有bower 任务:

bower: {
    dev: {
        dest: 'lib'// will get stuff from 'bower_components' to 'lib' folder
    }
},

所以当我这样做时:grunt bower 它会将 一些 内容从 bower_component 文件夹转换为 lib.. 所以我最终会在 /lib 中拥有类似 angular.js 的文件.

但它不会复制"angular.min.js",它位于bower_component

问:如何配置 grunt bower 任务来复制缩小的 v 文件?

我现在还不想将缩小/丑化任务放到 GruntFile 中。因为这些文件已经在bower_components 中被缩小了。

【问题讨论】:

    标签: gruntjs bower


    【解决方案1】:

    您应该使用 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 文件的内容。

    【讨论】:

    • 是你使用bower-components/**/*.min.js而不是bower_components/**/*.min.js的问题吗?
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2014-11-04
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多