如何在 dist 目录而不是 app 目录中运行 grunt 服务器? [英] How to run grunt server in dist directory instead of app directory?

查看:20
本文介绍了如何在 dist 目录而不是 app 目录中运行 grunt 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

grunt build 将我的 AngularJS 应用程序放到我的 dist 目录之后,我想用 grunt server 测试它.问题是 grunt server 只是提供我 app/ 目录中的所有代码.此外,请记住,我使用 yo angular 创建了我的应用程序.

After grunt building my AngularJS app to my dist directory, I would like to test it out with grunt server. Problem is that grunt server just serves up all the code in my app/ directory. Additionally, keep in mind that I created my app with yo angular.

这是我的 Gruntfile.js

grunt.registerTask('server', [
    'clean:server',
    'coffee:dist',
    'compass:server',
    'livereload-start',
    'connect:livereload',
    'open',
    'watch'
  ]);

有没有办法让 grunt server 只在我的 dist/ 目录中提供构建的代码?

Is there a way to make grunt server only serve up the built code in my dist/ directory?

推荐答案

能不能做到并不重要.重要的是你不应该为此使用 grunt 服务器. 你可以看到 grunt 中的服务器任务做了很多你在 dist 文件夹中不需要的事情,以及事实上它们都将被硬编码到您的应用文件夹中.

Whether or not you could do it isn't important. What is important is that you should not use grunt server for this. The server task in grunt as you can see does many things that you don't need in a dist folder, as well as the fact that they will all be hard coded for your app folder.

如果你只是想试试dist文件夹的结果,你应该做的就是cd进入dist目录,然后启动一个简单的HTTP服务器,就像p​​ython自带的那样.

If you just want to try out the result of the dist folder, what you should do is just cd into the dist directory and then start a simple HTTP server like the one that comes with python.

python -m SimpleHTTPServer

那应该会启动一个小型服务器让你尝试 dist 目录.

That should start a small server for you to try the dist directory out.

这篇关于如何在 dist 目录而不是 app 目录中运行 grunt 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆