Bower and Grunt Workflow

I just want to get an opinion on my workflow. I know Yomen and specifically decided not to use it. My workflow is as follows:

  • Run bower install to install all the dependencies on the project assets.
  • Run grunt , which copies all js files from the bower components folder to the new js folder and all css files to the new css folder.
  • Further use of the grunt task to concatenate and minimize all js and css files from new folders and put them in the dist folder.
  • Refer to the latest mini css and js in the dist folder from HTML.

One thing that I certainly do not want to do in my grunt task is to execute a dependency depending on a specific task, for example. grab all the js files from the bootstrap folder into the new js folder, then take all the js files from the prettyphoto folder into the new js folder. I want the grunt task to be as general as possible so that I can use the same grunt file in any project, no matter how the dependencies between them look. The reason is that I have to spend all the time creating my grunt file for each project, why don't I just grab the source code for all the dependencies in the usual way.

So, there is the grunt-contrib-copy plugin for copying files from one place to another, which I use to capture all js files from the bower components folder. The problem is that most bowler components come with regular js and a shortened version. So, I copy them and concatenate and broaden them. So repeat the code!

Does my workflow make sense? So, how can I get rid of the problem that I mentioned in the previous paragraph?

+6
source share
1 answer

If I understand correctly, you should take a look at grunt-usemin . You can wrap js tags in <!-- build:js js/foo.js --> . The useminPrepare task included in the package will cycle through any scripts (or css, or images, etc.) that exist, and dynamically add them to the concat or uglify task.

The only drawback I found is that the usemin task is rather slow, but hopefully if this pull request is implemented, everything will be much, much faster.

+2
source

Source: https://habr.com/ru/post/946211/


All Articles