1

In an inherited polymer 1.0 project the setup involves a gruntfile which calls, among other things, bower to install the necessary resources. However, in the later steps, some files cannot be found and the grunt task fails. I am new to both bower and grunt and feeling a little lost.

The file in question that cannot be found is myproject\components\polymer\polymer-mini.html, though there are more in similar positions which I found out by copying the file there by hand.

My first step was to isolate the bower install task and watch it while it was working. This is its configuration in the gruntfile.js:

bower: { install: { options: { targetDir: './components', layout: 'byType', install: true, verbose: false, cleanTargetDir: true, cleanBowerDir: true, bowerOptions: {} } } } 

By pausing the execution after single steps in verbose mode I found the following to happen during installation:

  • the old myproject/components folder is deleted if it exists
  • files are created as normal in a myproject/bower_components folder
  • files are then copied to the targetDir myproject/components
  • however, not all files seem to arrive there
  • myproject/bower_components is deleted after copying

Comparing the contents of myproject/bower_components and myproject/components reveals that many files present in the original folder are missing in the target one. For example, the mentioned myproject/components/polymer only contains a polymer.html - however, there are seven files in myproject/bower_components/polymer, including the missing polymer-mini.html.

Apparently, something filters what is copied to the targetDir and what isn't.

Can I influence this in any way or is this setup even correct as it is now? I have seen grunt-bower-task and Polymer but cannot make much of it - except that the accepted solution apparently copies everything by hand after the installation of bower_components. Surely, there must be a better way?

1 Answer 1

1

I ended up copying the files independently of the bower task by calling a copy task configured as such:

copy: { main: { files: [ { expand: true, cwd: 'bower_components/', src: ['**'], dest: 'components/', filter: 'isFile' }, // bower components ] } } 

Of course, in this case the bower task has to be reconfigured not to delete the bower directory from which to copy.

bower: { install: { options: { targetDir: './components', layout: 'byType', install: true, verbose: false, cleanTargetDir: true, cleanBowerDir: false, bowerOptions: {} } } } 

This isn't really what I hoped for but in the meantime it gets the job done.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.