mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 09:24:52 +03:00
Add a DummyWebpackLoader for running tests
This commit is contained in:
parent
826712d2b3
commit
93f2a1e87c
|
@ -101,6 +101,13 @@ def remove_gulp_files():
|
||||||
def remove_webpack_files():
|
def remove_webpack_files():
|
||||||
shutil.rmtree("webpack")
|
shutil.rmtree("webpack")
|
||||||
remove_vendors_js()
|
remove_vendors_js()
|
||||||
|
os.remove(
|
||||||
|
os.path.join(
|
||||||
|
"{{ cookiecutter.project_slug }}",
|
||||||
|
"utils",
|
||||||
|
"loaders.py",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def remove_vendors_js():
|
def remove_vendors_js():
|
||||||
|
|
|
@ -29,5 +29,13 @@ EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
TEMPLATES[0]["OPTIONS"]["debug"] = True # type: ignore # noqa F405
|
TEMPLATES[0]["OPTIONS"]["debug"] = True # type: ignore # noqa F405
|
||||||
|
|
||||||
|
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
|
||||||
|
# django-webpack-loader
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
WEBPACK_LOADER["DEFAULT"][ # noqa F405
|
||||||
|
"LOADER_CLASS"
|
||||||
|
] = "{{cookiecutter.project_slug}}.utils.loaders.DummyWebpackLoader"
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
# Your stuff...
|
# Your stuff...
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
from webpack_loader.loader import WebpackLoader
|
||||||
|
|
||||||
|
|
||||||
|
class DummyWebpackLoader(WebpackLoader):
|
||||||
|
def get_bundle(self, _bundle_name: str):
|
||||||
|
"""
|
||||||
|
Dummy loader to run tests.
|
||||||
|
|
||||||
|
Needed to run tests without webpack stats file nor bundle built.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"name": "test.bundle.js",
|
||||||
|
"url": "http://localhost/static/bundles/test.bundle.js",
|
||||||
|
},
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user