mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-17 02:14:53 +03:00
Run Django + Webpack dev server concurrently without Docker
This commit is contained in:
parent
d566190ad2
commit
121d4d347f
|
@ -27,7 +27,7 @@ production-ready Django projects quickly.
|
|||
- Registration via [django-allauth](https://github.com/pennersr/django-allauth)
|
||||
- Comes with custom user model ready to go
|
||||
- Optional basic ASGI setup for Websockets
|
||||
- Optional custom static build using Gulp and livereload
|
||||
- Optional custom static build using Gulp or Webpack
|
||||
- Send emails via [Anymail](https://github.com/anymail/django-anymail) (using [Mailgun](http://www.mailgun.com/) by default or Amazon SES if AWS is selected cloud provider, but switchable)
|
||||
- Media storage using Amazon S3 or Google Cloud Storage
|
||||
- Docker support using [docker-compose](https://github.com/docker/compose) for development and production (using [Traefik](https://traefik.io/) with [LetsEncrypt](https://letsencrypt.org/) support)
|
||||
|
|
|
@ -136,13 +136,14 @@ def update_package_json(remove_dev_deps=None, remove_keys=None, scripts=None):
|
|||
fd.write("\n")
|
||||
|
||||
|
||||
def handle_js_runner(choice):
|
||||
def handle_js_runner(choice, use_docker, use_async):
|
||||
if choice == "Gulp":
|
||||
update_package_json(
|
||||
remove_dev_deps=[
|
||||
"@babel/core",
|
||||
"@babel/preset-env",
|
||||
"babel-loader",
|
||||
"concurrently",
|
||||
"css-loader",
|
||||
"mini-css-extract-plugin",
|
||||
"postcss-loader",
|
||||
|
@ -162,23 +163,37 @@ def handle_js_runner(choice):
|
|||
)
|
||||
remove_webpack_files()
|
||||
elif choice == "Webpack":
|
||||
update_package_json(
|
||||
remove_dev_deps=[
|
||||
"browser-sync",
|
||||
"cssnano",
|
||||
"gulp",
|
||||
"gulp-imagemin",
|
||||
"gulp-plumber",
|
||||
"gulp-postcss",
|
||||
"gulp-rename",
|
||||
"gulp-sass",
|
||||
"gulp-uglify-es",
|
||||
],
|
||||
scripts={
|
||||
"dev": "webpack serve --config webpack/dev.config.js ",
|
||||
"build": "webpack --config webpack/prod.config.js",
|
||||
},
|
||||
)
|
||||
scripts = {
|
||||
"dev": "webpack serve --config webpack/dev.config.js",
|
||||
"build": "webpack --config webpack/prod.config.js",
|
||||
}
|
||||
remove_dev_deps = [
|
||||
"browser-sync",
|
||||
"cssnano",
|
||||
"gulp",
|
||||
"gulp-imagemin",
|
||||
"gulp-plumber",
|
||||
"gulp-postcss",
|
||||
"gulp-rename",
|
||||
"gulp-sass",
|
||||
"gulp-uglify-es",
|
||||
]
|
||||
if not use_docker:
|
||||
dev_django_cmd = (
|
||||
"gunicorn config.asgi -k uvicorn.workers.UvicornWorker --reload"
|
||||
if use_async
|
||||
else "python manage.py runserver_plus"
|
||||
)
|
||||
scripts.update(
|
||||
{
|
||||
"dev": "concurrently npm:dev:*",
|
||||
"dev:webpack": "webpack serve --config webpack/dev.config.js",
|
||||
"dev:django": dev_django_cmd,
|
||||
}
|
||||
)
|
||||
else:
|
||||
remove_dev_deps.append("concurrently")
|
||||
update_package_json(remove_dev_deps=remove_dev_deps, scripts=scripts)
|
||||
remove_gulp_files()
|
||||
|
||||
|
||||
|
@ -469,7 +484,11 @@ def main():
|
|||
if "{{ cookiecutter.use_docker }}".lower() == "y":
|
||||
remove_node_dockerfile()
|
||||
else:
|
||||
handle_js_runner("{{ cookiecutter.frontend_pipeline }}")
|
||||
handle_js_runner(
|
||||
"{{ cookiecutter.frontend_pipeline }}",
|
||||
use_docker=("{{ cookiecutter.use_docker }}".lower() == "y"),
|
||||
use_async=("{{ cookiecutter.use_async }}".lower() == "y"),
|
||||
)
|
||||
|
||||
if "{{ cookiecutter.cloud_provider }}" == "None":
|
||||
print(
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"browser-sync": "^2.27.7",
|
||||
"css-loader": "^6.5.1",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"concurrently": "^7.0.0",
|
||||
"cssnano": "^5.0.11",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-imagemin": "^7.1.0",
|
||||
|
|
Loading…
Reference in New Issue
Block a user