Justin XL
Justin XL

Reputation: 39006

grunt-bower-task and Polymer

I cannot seem to find an easy way to copy all the files from Polymer to using grunt-bower-task.

grunt.initConfig({
    bower: {
        install: {
            options: {
                targetDir: 'wwwroot/lib',
                layout: 'byComponent',
                install: true,
                copy: true,
                verbose: true,
                cleanTargetDir: false,
                bowerOptions: {}
            }
        }
    }

I understand that only the main files defined inside each element's bower.json file get copied over. I am also aware that I could put a exportsOverride section in my own bower.json to include more files like this -

  "exportsOverride": {
    "*": {
      "": "*.*",
      "demo": "demo/*.*",
      "test": "test/*.*"
    }
  }

But this doesn't cover all cases as some elements have more sub-folders than just demo and test. Do I have to manually look them all up and add their paths to the exportsOverride, or there's an easy way that I've overlooked?

Upvotes: 4

Views: 274

Answers (1)

Robert Rowntree
Robert Rowntree

Reputation: 6289

hate to provide a sample of a fail....

FWIW recently , i had very similar issue ... worked it and failed

what i did is abandon the attempt to flatten everything out in the "dist" tag for a first polymer project. Rather i just ran minify/ugly on one or two elements leaving the HTTP2 type file structure ( deep and many many, dirs/files. )

// the process belo NG . Manual edit needed on "polymer-min.html" go end and chg the js file name   
    copy: {
      main: {
        files: [
          // includes files within path
          {expand: true, src: ['*html'], dest: 'dest/', filter: 'isFile'},
          // includes files within path and its sub-directories
          {expand: true, src: ['js/**', 'images/**' ,'css/**' ,'elements/**' ,'bower_components/**'], dest: 'dest/'},
        { src: ['tmp/csp/build-csp.html'], dest: 'dest/bower_components/cast-button-polymer/cast-button-polymer-min.html', 
            filter: 'isFile',
            options: {
              process: function (content, srcpath) {
                return content.replace(/build-csp.js/g,"cast-button-polymer-min.js");
              },
            },
            },
        { src: ['tmp/csp/build-csp-min.js'], dest: 'dest/bower_components/cast-button-polymer/cast-button-polymer-min.js', filter: 'isFile'},         
        ],
      },
},

Upvotes: 1

Related Questions