-->

can grunt server use for production application de

2019-01-22 22:38发布

问题:

i am at fresher level,i want to know about the Grunt server is able to handle production application deployment.

.. please help me.

回答1:

Yes you can run grunt in production, You can see this post for how to do it.

What's the purpose of gruntjs server task?

But, i woudn't recommend that.

Grunt server is basically designed to help the developer to run your app, without using an actual server. Apart from serving pages, It does some tasks like compiling sass, less files and reloading the page using live-reload, etc,. whenever you change these files and any additional tasks based on the config you provide in Gruntfile.js

But in a production server, you might expect a lot of traffic and every time files changes recompiling the files and all is lot of mess. I don't think Grunt server can handle the traffic in production and all the tasks, your site may become very slow.

Also Angular is front-end framework, so how do you plan to use any web services with it? To run web services you might be running Apache or node server. so you can deploy your app build in the same server.

You can do all these in your development and you build the app and place it in production site

You can use Grunt Build command to build your angular app and it will give minified javascript, css and other things in dist folder

You can deploy this minified app in your production server. very less code is transfered to the client so you can reduce lot of bandwidth stress on the server and your application will be faster.

Choose Wisely :)



回答2:

Yes, you can. But to do it would be madness. So... I'd say no, don't do it.

A Grunt "server" (in quotes because it actually runs on top of NodeJS) is only meant for local development. However, Grunt runs on NodeJS, and with the help of some frameworks like ExpressJS you can get something to work on NodeJS. See this Deploying a production Node.js server.

Grunt is a task runner, it's meant to help one develop faster. But Grunt won't deliver production-ready builds every time you run tasks. It will help you get there by letting you know what you need to fix to get a production-ready build. When you do that - and only then - you may release the latest build. Combine it with a version control tool like Git and you are covered.

Make sure you are self-employed before serving live Grunt builds on a production server, so you don't loose your job... :)