1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gulpコマンド一つでsassやjsをwatchしながらDjangoも立ち上げる

Last updated at Posted at 2018-12-28

gulpと打つだけでjsとかsassのwatchをしつつDjangoのアプリケーションも立ち上げたい。

参考サイト
http://dae.me/blog/2111/run-django-dev-server-with-gulp/
https://gist.github.com/EtienneR/a7d9e956ace886516299

gulpfile.js
'use strict';

const gulp = require('gulp');
const child = require('child_process');

var server = null;

gulp.task('server:spawn', () => {
  if (server && server !== 'null') {
    server.kill();
  }

  server = child.spawn('python', ['manage.py', 'runserver'], { stdio: 'inherit' });

  server.on('close', (code) => {
    if (code !== 0) {
      console.error('Django runserver exited with error code: ' + code);
    } else {
      console.log('Django runserver exited normally.');
    }
  });

});
gulp.task('default', ['server:spawn'])

アプリケーションの起動ってコマンド一つで動くのがあるべき姿だと思ってます。
複雑な手順だとデザイナーの方には難しいし、
手順が簡単だとちょっとHTML直すくらいだったら企画の人でもやってくれるようになる。
スタートアップとか人数少ないチームだとこういうのって結構重要な事なんじゃないかと。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?