UNPKG

2.12 kBMarkdownView Raw
1# Django Apps Jest Mapper
2[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
3[![license](https://img.shields.io/github/license/marinko-peso/django-apps-jest-mapper.svg)](https://github.com/marinko-peso/django-apps-jest-mapper/blob/master/LICENSE)
4[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/Flet/semistandard)
5[![package version](https://img.shields.io/npm/v/django-apps-jest-mapper.svg)](https://npm.im/django-apps-jest-mapper)
6[![install size](https://packagephobia.now.sh/badge?p=django-apps-jest-mapper)](https://packagephobia.now.sh/result?p=django-apps-jest-mapper)
7[![dependecies](https://david-dm.org/marinko-peso/django-apps-jest-mapper.svg)](https://david-dm.org/marinko-peso/django-apps-jest-mapper)
8[![codecov](https://codecov.io/gh/marinko-peso/django-apps-jest-mapper/branch/master/graph/badge.svg)](https://codecov.io/gh/marinko-peso/django-apps-jest-mapper)
9
10Automatically discovery django apps and map jest names for them.
11
12## Why?
13
14If you need to start using Jest combined with Webpack on a Django organized project this package can work great together with [django-apps-webpack-alias](https://npm.im/django-apps-webpack-alias). Static files are usually organized per Django app, and communication between them using relative paths can soon become messy.
15This way you can generate same Webpack alias for all Django apps automatically and follow the same naming in the jest configuration.
16
17
18## Install
19
20```ssh
21npm i -D django-apps-jest-mapper
22```
23
24
25## Running
26
27```js
28const djangoAppsMapper = require('django-apps-jest-mapper');
29
30// in jest moduleNameMapper config just spread it (or Object.assign with other entries)
31moduleNameMapper: {
32 ...djangoAppsMapper({ options })
33},
34```
35
36Available options:
37- dir [default 'apps'] path to directory holding the apps
38- prefix [default '@app:'] each app prefix, for instance for auth app it will generate ``` @app:auth ```
39
40All mappings point to app/static/app/js directory for each app.
41
42
43## License
44
45MIT.
46
\No newline at end of file