Doubts regarding the Grunt

Asked

Viewed 36 times

1

I’m not very experienced in javascript and wanted to know what would be a production version. I’m using the Grunt to concatenate and minify my application in order to make it smaller. The files generated by this process (app.js, app.min.js) end up inside the folder dist/js/.

So we have this structure:

APP
  | -- dist -- js -- app.js / app.min.js
  | -- images
  | -- scripts / controllers / services / etc
  | -- bower_components / dependencias
  | -- node_modules / ...
  | -- views

My question is: when we put this in production, we play the entire APP folder or put it in the process of Grunt, for it to copy the content of images, views and generate a version within dist, in which would be independent of other resources

1 answer

2


When using the Grunt, you are generating packages for various environments. The folder you put into production is the dist the App folder serves as a development environment, it would be good for you to include a task to upload the images files to the dist folder as well.

About Grunt.

Think of Grunt as a task calculator. Some tasks take time and can lead to errors Grunt will automate this. In your Gruntfile.js you will define which tasks and can also modify and include other tasks, including modifying the output of production files.

If you need sometimes a package for testing and others for production, you can also define this, it will to your liking and also many queries the documentation of Grunt

  • So dist should contain all my dependencies, including the imported scripts?

  • 1

    Exactly, if you are not using a CDN, you should put it in some other folder and concatenate and minify the files and configure Grunt to leave everything in your folder dist. I’m going to link a repository to Github, which I used Grunt to check. It’s one of my first uses with Grunt, but you can get an idea. https://github.com/flpms/MQBC

  • Thanks for the help! I’ll try to see ways to copy the dependency files, like the Angularjs inside the Bower folder. Thanks anyway

  • So in this case you can reference the Angular file in your gruntfile.

  • But in this case, I would have to for each file, manually reference, right?

  • Yes. I don’t know if Angular already provides this in Gruntfile.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.