使用runserver和collectstatic运行gulp任务

django-gulp的Python项目详细描述


django-gulp重写./manage.py runserver./manage.py collectstatic这样他们也能执行你的任务。

我把这个和watchify和livereload一起用了,所以 我的简单的未经修饰的运行服务器会自动监视和编译 带有browserify和live的新javascript文件重新加载新css 从sass自动编译而成。

安装

像这样将"django_gulp"添加到INSTALLED_APPS设置中, 确保它在django.contrib.staticfiles(或 覆盖列表中runservercollectstatic的其他应用程序 如果已列出):

INSTALLED_APPS = (
    'django_gulp',
    ...
)

现在当您运行./manage.py runserver./manage.py collectstatic您的gulp任务也将运行!

设置

GULP_CWD默认为当前工作目录。覆盖它,如果 您的gulpfile.js不在django项目的 顶层目录。

GULP_PRODUCTION_COMMAND默认为gulp build --productionGULP_DEVELOP_COMMAND默认为gulp。请注意,在指定 手动设置,GULP_CWD被忽略。

英雄

django-gulp对heroku有效!你只需要使用buildpack multi 并确保您的.buildpacks文件如下:

https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-python.git

使用buildback multi设置您的配置如下:

$ heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-multi.git

示例输出

$ ./manage.py runserver
>>> Starting gulp
>>> gulp process on pid 47863
Performing system checks...

System check identified no issues.
May 04, 2015 - 18:27:52
Django version 1.8.1, using settings 'example.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[18:27:53] Using gulpfile ~/p/example/gulpfile.js
[18:27:53] Starting 'bower-install'...
[18:27:54] Using cwd:  /Users/beau/p/example
[18:27:54] Using bower dir:  static/vendor
[18:27:54] Starting 'sass'...
[18:27:54] Starting 'watch'...
[18:27:54] Finished 'watch' after 19 ms
[18:27:54] Starting 'watchify'...
[18:28:08] Watching files required by bundle-about.js
[18:28:08] Bundling bundle-about.js...
[18:28:08] Watching files required by bundle-accounts-login.js
[18:28:08] Bundling bundle-accounts-login.js...
[18:28:08] Watching files required by bundle-accounts-signup.js
[18:28:08] Bundling bundle-accounts-signup.js...
[18:28:08] Watching files required by bundle-activities.js
[18:28:08] Bundling bundle-activities.js...
[18:28:08] Finished 'watchify' after 14 s
[18:28:09] Finished 'sass' after 15 s
^C>>> Closing gulp process
$ ./manage.py collectstatic
[18:32:54] Using gulpfile ~/p/example/gulpfile.js
[18:32:54] Starting 'bower-install'...
[18:32:55] Using cwd:  /Users/beau/p/example
[18:32:55] Using bower dir:  static/vendor
[18:32:55] Starting 'sass'...
[18:32:56] Starting 'browserify'...
[18:33:05] Bundling bundle-about.js...
[18:33:05] Bundling bundle-accounts-login.js...
[18:33:05] Bundling bundle-accounts-signup.js...
[18:33:05] Bundling bundle-activities.js...
[18:33:05] Finished 'browserify' after 9.39 s
[18:33:08] Finished 'sass' after 13 s
[18:33:14] Finished 'bower-install' after 19 s
[18:33:14] Starting 'bower-main-files'...
[18:33:14] Starting 'bower-detritus'...
[18:33:14] Finished 'bower-main-files' after 104 ms
[18:33:14] Finished 'bower-detritus' after 507 ms
[18:33:14] Starting 'bower'...
[18:33:14] Finished 'bower' after 18 μs
[18:33:14] Starting 'build'...
[18:33:14] Finished 'build' after 5 μs

You have requested to collect static files at the destination
location as specified in your settings:

    /Users/beau/p/example/static-files

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Copying '/Users/beau/p/example/build/js/bundle-about.js'
Copying '/Users/beau/p/example/build/js/bundle-about.map.json'
Copying '/Users/beau/p/example/build/js/bundle-accounts-login.js'
Copying '/Users/beau/p/example/build/js/bundle-accounts-login.map.json'
Copying '/Users/beau/p/example/build/js/bundle-accounts-signup.js'
Copying '/Users/beau/p/example/build/js/bundle-accounts-signup.map.json'
Copying '/Users/beau/p/example/build/js/bundle-activities.js'
Copying '/Users/beau/p/example/build/js/bundle-activities.map.json'

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有多用户OU和多访问CNs的java Spring LDAP身份验证   java分配的变量神秘地变为null   java比较两个表或文本文件,并用行号和列输出差异   java如何在同一构建目录中设置netbeans中的文件路径?   java如何在avro模式中定义byte[]和LocalDateTime?   java在多个活动和片段中使用相同的微调器。实施它的最佳方式是什么?   java使用OOPS扩展已编写的类   java如何在特定于文件的基础上禁用Eclipse中的编译器警告?   java将字符串转换为日期的格式不正确   Java文件从一台服务器复制到另一台服务器   java Jacksonal和JacksonApperasl的最新jar版本是什么?   java如何在使用selenium chrome web驱动程序时禁用chrome中的身份验证提示   java是什么。推荐人和推荐人。Eclipse工作区中的元数据以及它们是否应该在设备之间同步?   java我应该把sqlite db文件放在哪里,这样我的jar就可以访问它了?这对连接字符串有何影响?   java如何在选择单元格时设置JTable标题背景色   java Cassandra 2 Hector:复合行键上的范围切片查询返回空行   java方法注释继承   Python字节对象与java   java Android和从sqlite数据库加载listview