django-serve-spa


Namedjango-serve-spa JSON
Version 0.1.0rc1 PyPI version JSON
download
home_pagehttps://github.com/kaoslabsinc/django-serve-spa
SummaryServe SPAs with Django
upload_time2023-01-25 23:24:15
maintainer
docs_urlNone
authorKaos Labs Inc.
requires_python
licenseBSD-3-Clause
keywords django spa react serve
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django serve SPA

Serve SPAs with Django

## Quick start

```shell
pip install django-serve-spa
```

Build your SPA and copy the contents of the build into `SPA_ROOT` (e.g. `path/to/django/spa/`).

```python
# settings.py
SPA_ROOT = BASE_DIR / 'spa'  # where the built SPA code will live
SPA_URL = ''  # To serve from /

# urls.py
from kaos_spa import settings as spa_settings

urlpatterns += [
    path(spa_settings.SPA_URL, include('kaos_spa.urls')),
]
```

Runserver, and visit `SPA_URL` (`/` by default). Your SPA will show up.

## Notes

`django-serve-spa` is meant to be used for development and isn't recommended for production use. For production, serve the
SPA on its own using tools like [npm serve](https://www.npmjs.com/package/serve).

`django-serve-spa` is mostly tested with create-react-app apps, but in theory should work with any SPA.

## Utility scripts

`django-serve-spa` comes bundled with some utility scripts that makes building and copying your SPA project much more
convenient.

### `build-spa`

Build your SPA and put it in your django project.

Set the following environment variables

```shell
# required
SPA_SRC_DIR=/path/to/your/spa/
SPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to

# optional
SPA_URL  # If you are not serving on /
SPA_BUILD_CMD="npm run build"
SPA_BUILD_DIR_PATH='build/'  # Where the build command builds the app in its src directory
```

run

```shell
build-spa
```

It'll build your SPA and put it in the right folder in your django project.

### `cm-spa-build`

Commits the new build into Git with commit message from arg. If no arg is supplied, commit message defaults to "New SPA
build".

Set the following environment variables

```shell
# required
SPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to
```

run

```shell
cm-spa-build
```

## Development and Testing

### IDE Setup

Add the `example` directory to the `PYTHONPATH` in your IDE to avoid seeing import warnings in the `tests` modules. If
you are using PyCharm, this is already set up.

### Running the Tests

Install requirements

```
pip install -r requirements.txt
```

For local environment

```
pytest
```

For all supported environments

```
tox
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kaoslabsinc/django-serve-spa",
    "name": "django-serve-spa",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,spa,react,serve",
    "author": "Kaos Labs Inc.",
    "author_email": "keyvan@keyvanm.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/6f/821fffe57559ae752054f2006afc7e0c907b37ac9b0c27542c12dd759b79/django-serve-spa-0.1.0rc1.tar.gz",
    "platform": null,
    "description": "# Django serve SPA\n\nServe SPAs with Django\n\n## Quick start\n\n```shell\npip install django-serve-spa\n```\n\nBuild your SPA and copy the contents of the build into `SPA_ROOT` (e.g. `path/to/django/spa/`).\n\n```python\n# settings.py\nSPA_ROOT = BASE_DIR / 'spa'  # where the built SPA code will live\nSPA_URL = ''  # To serve from /\n\n# urls.py\nfrom kaos_spa import settings as spa_settings\n\nurlpatterns += [\n    path(spa_settings.SPA_URL, include('kaos_spa.urls')),\n]\n```\n\nRunserver, and visit `SPA_URL` (`/` by default). Your SPA will show up.\n\n## Notes\n\n`django-serve-spa` is meant to be used for development and isn't recommended for production use. For production, serve the\nSPA on its own using tools like [npm serve](https://www.npmjs.com/package/serve).\n\n`django-serve-spa` is mostly tested with create-react-app apps, but in theory should work with any SPA.\n\n## Utility scripts\n\n`django-serve-spa` comes bundled with some utility scripts that makes building and copying your SPA project much more\nconvenient.\n\n### `build-spa`\n\nBuild your SPA and put it in your django project.\n\nSet the following environment variables\n\n```shell\n# required\nSPA_SRC_DIR=/path/to/your/spa/\nSPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to\n\n# optional\nSPA_URL  # If you are not serving on /\nSPA_BUILD_CMD=\"npm run build\"\nSPA_BUILD_DIR_PATH='build/'  # Where the build command builds the app in its src directory\n```\n\nrun\n\n```shell\nbuild-spa\n```\n\nIt'll build your SPA and put it in the right folder in your django project.\n\n### `cm-spa-build`\n\nCommits the new build into Git with commit message from arg. If no arg is supplied, commit message defaults to \"New SPA\nbuild\".\n\nSet the following environment variables\n\n```shell\n# required\nSPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to\n```\n\nrun\n\n```shell\ncm-spa-build\n```\n\n## Development and Testing\n\n### IDE Setup\n\nAdd the `example` directory to the `PYTHONPATH` in your IDE to avoid seeing import warnings in the `tests` modules. If\nyou are using PyCharm, this is already set up.\n\n### Running the Tests\n\nInstall requirements\n\n```\npip install -r requirements.txt\n```\n\nFor local environment\n\n```\npytest\n```\n\nFor all supported environments\n\n```\ntox\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Serve SPAs with Django",
    "version": "0.1.0rc1",
    "split_keywords": [
        "django",
        "spa",
        "react",
        "serve"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47f5cdb6124154cfffbe8be8f0250a7c0cf0ab7452499b1e2466349071d589c6",
                "md5": "dd356ca9661fe74f070e1650d70b925a",
                "sha256": "b1379629e7128529ca964de08413db3746e711ea4ec3f91599f7b36001b920a9"
            },
            "downloads": -1,
            "filename": "django_serve_spa-0.1.0rc1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd356ca9661fe74f070e1650d70b925a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7368,
            "upload_time": "2023-01-25T23:24:13",
            "upload_time_iso_8601": "2023-01-25T23:24:13.277855Z",
            "url": "https://files.pythonhosted.org/packages/47/f5/cdb6124154cfffbe8be8f0250a7c0cf0ab7452499b1e2466349071d589c6/django_serve_spa-0.1.0rc1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e76f821fffe57559ae752054f2006afc7e0c907b37ac9b0c27542c12dd759b79",
                "md5": "409ba8d421d8df44d1a52dd94fa3b088",
                "sha256": "19badd358d884b3684340242ef8abdbbd0ee3c74423050f912305d6e92e4a033"
            },
            "downloads": -1,
            "filename": "django-serve-spa-0.1.0rc1.tar.gz",
            "has_sig": false,
            "md5_digest": "409ba8d421d8df44d1a52dd94fa3b088",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5804,
            "upload_time": "2023-01-25T23:24:15",
            "upload_time_iso_8601": "2023-01-25T23:24:15.050647Z",
            "url": "https://files.pythonhosted.org/packages/e7/6f/821fffe57559ae752054f2006afc7e0c907b37ac9b0c27542c12dd759b79/django-serve-spa-0.1.0rc1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-25 23:24:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "kaoslabsinc",
    "github_project": "django-serve-spa",
    "lcname": "django-serve-spa"
}
        
Elapsed time: 0.07392s