-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simpler Webpack 5 config #637
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c56a7bc
Simpler Webpack 5 config
fjsj 452ba80
Fix package.json
fjsj 8ccb015
Drop generated poetry.lock
fjsj 28cd256
Fix tests
fjsj 729df5b
Fix .eslintrc.js
fjsj a9d8223
parserOptions in .eslintrc.js
fjsj 84f1b6b
Fix eslint config
fjsj 54ecef2
Restore default-param-last
fjsj 8bd62c4
Fix eslint
fjsj 20a6ec8
Add minimize
fjsj e240ca5
ruff --fix .
fjsj 5e0a525
ruff check backend only
fjsj 483d46f
Fix pre-commit config
fjsj caacc28
Improve startproject command
fjsj 832f508
Fix ruff in action.yml
fjsj 09850d9
Fix ruff in action.yml
fjsj a920924
Use const
fjsj e7d3c07
Fix source-map
fjsj cbaafda
Small fix on regex of WEBPACK_LOADER
fjsj c207168
Rename master to main in other files
fjsj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
fail_fast: true | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: ['--maxkb=500'] | ||
exclude: > | ||
(?x)^( | ||
package-lock\.json | ||
)$ | ||
- id: fix-byte-order-marker | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.1.6 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [ --fix ] | ||
# Run the formatter. | ||
- id: ruff-format | ||
- repo: local | ||
hooks: | ||
- id: eslint | ||
name: eslint-local | ||
entry: npm run lint | ||
language: system | ||
types: [javascript] | ||
exclude: > | ||
(?x)^( | ||
.+\.config\.js| | ||
server\.js| | ||
\.eslintrc\.js | ||
)$ | ||
pass_filenames: true | ||
- id: missing-migrations | ||
name: missing-migrations-local | ||
entry: poetry run python backend/manage.py makemigrations --check | ||
language: system | ||
# Only run missing migration check if migration-generating files have changed: | ||
files: (.*/?(settings|migrations|models)/.+|.+models\.py|.+constants\.py|.+choices\.py|.+pyproject\.toml) | ||
pass_filenames: false | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: ["--maxkb=500"] | ||
exclude: > | ||
(?x)^( | ||
package-lock\.json | ||
)$ | ||
- id: fix-byte-order-marker | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.1.6 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
args: [--fix] | ||
# Run the formatter. | ||
- id: ruff-format | ||
- repo: local | ||
hooks: | ||
- id: eslint | ||
name: eslint-local | ||
entry: npm run lint | ||
language: system | ||
types: [javascript] | ||
exclude: > | ||
(?x)^( | ||
.+\.config\.js| | ||
.+\.setup\.js| | ||
\.eslintrc\.js | ||
)$ | ||
pass_filenames: true | ||
- id: missing-migrations | ||
name: missing-migrations-local | ||
entry: poetry run python backend/manage.py makemigrations --check | ||
language: system | ||
# Only run missing migration check if migration-generating files have changed: | ||
files: (.*/?(settings|migrations|models)/.+|.+models\.py|.+constants\.py|.+choices\.py|.+pyproject\.toml) | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,11 +68,11 @@ Send us an email at [email protected] telling us a bit more about how ou | |
- [ ] Open the command line and go to the directory you want to start your project in. | ||
- [ ] Start your project using: | ||
``` | ||
django-admin startproject {{project_name}} --extension py,json,yml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip | ||
django-admin startproject {{project_name}} --extension py,json,yml,yaml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip | ||
``` | ||
Alternatively, you may start the project in the current directory by placing a `.` right after the project name, using the following command: | ||
``` | ||
django-admin startproject {{project_name}} . --extension py,json,yml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip | ||
django-admin startproject {{project_name}} . --extension py,json,yml,yaml,toml --name Dockerfile,README.md,.env.example,.gitignore,Makefile --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip | ||
``` | ||
In the next steps, always remember to replace {{project_name}} with your project's name (in case it isn't yet): | ||
- [ ] Above: don't forget the `--extension` and `--name` params! | ||
|
@@ -88,14 +88,14 @@ After completing ALL of the above, remove this `Project bootstrap` section from | |
- Setup [editorconfig](http://editorconfig.org/), [ruff](https://github.com/astral-sh/ruff) and [ESLint](http://eslint.org/) in the text editor you will use to develop. | ||
|
||
### Setup | ||
- Inside the `backend` folder, do the following: | ||
- Create a copy of `{{project_name}}/settings/local.py.example`: | ||
`cp {{project_name}}/settings/local.py.example {{project_name}}/settings/local.py` | ||
- Create a copy of `.env.example`: | ||
`cp .env.example .env` | ||
- Do the following: | ||
- Create a git-untracked `local.py` settings file: | ||
`cp backend/{{project_name}}/settings/local.py.example backend/{{project_name}}/settings/local.py` | ||
- Create a git-untracked `.env.example` file: | ||
`cp backend/.env.example backend/.env` | ||
|
||
### If you are using Docker: | ||
- Open the `/backend/.env` file on a text editor and uncomment the line `DATABASE_URL=postgres://{{project_name}}:password@db:5432/{{project_name}}` | ||
- Open the `backend/.env` file on a text editor and uncomment the line `DATABASE_URL=postgres://{{project_name}}:password@db:5432/{{project_name}}` | ||
- Open a new command line window and go to the project's directory | ||
- Run the initial setup: | ||
`make docker_setup` | ||
|
@@ -131,7 +131,7 @@ After completing ALL of the above, remove this `Project bootstrap` section from | |
- This is used to serve the frontend assets to be consumed by [django-webpack-loader](https://github.com/django-webpack/django-webpack-loader) and not to run the React application as usual, so don't worry if you try to check what's running on port 3000 and see an error on your browser | ||
|
||
#### Setup the backend app | ||
- Open the `/backend/.env` file on a text editor and do one of the following: | ||
- Open the `backend/.env` file on a text editor and do one of the following: | ||
- If you wish to use SQLite locally, uncomment the line `DATABASE_URL=sqlite:///backend/db.sqlite3` | ||
- If you wish to use PostgreSQL locally, uncomment and edit the line `DATABASE_URL=postgres://{{project_name}}:password@db:5432/{{project_name}}` in order to make it correctly point to your database URL | ||
- The url format is the following: `postgres://USER:PASSWORD@HOST:PORT/NAME` | ||
|
@@ -247,14 +247,17 @@ After enabling dyno metadata and setting the environment variables, your next Re | |
## Opinionated Settings | ||
Some settings defaults were decided based on Vinta's experiences. Here's the rationale behind them: | ||
|
||
### `DATABASES["default"]["ATOMIC_REQUESTS"] = True` | ||
Using atomic requests in production prevents several database consistency issues. Check [Django docs for more details](https://docs.djangoproject.com/en/4.2/topics/db/transactions/#tying-transactions-to-http-requests). | ||
|
||
### `CELERY_ACKS_LATE = True` | ||
We believe Celery tasks should be idempotent. So for us it's safe to set `CELERY_ACKS_LATE = True` to ensure tasks will be re-queued after a worker failure. Check Celery docs on ["Should I use retry or acks_late?"](https://docs.celeryq.dev/en/stable/faq.html#faq-acks-late-vs-retry) for more info. | ||
|
||
## Contributing | ||
|
||
If you wish to contribute to this project, please first discuss the change you wish to make via an [issue](https://github.com/vintasoftware/django-react-boilerplate/issues). | ||
|
||
Check our [contributing guide](https://github.com/vintasoftware/django-react-boilerplate/blob/master/CONTRIBUTING.md) to learn more about our development process and how you can test your changes to the boilerplate. | ||
Check our [contributing guide](https://github.com/vintasoftware/django-react-boilerplate/blob/main/CONTRIBUTING.md) to learn more about our development process and how you can test your changes to the boilerplate. | ||
|
||
## Commercial Support | ||
[![alt text](https://avatars2.githubusercontent.com/u/5529080?s=80&v=4 "Vinta Logo")](https://www.vinta.com.br/) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"useBuiltIns": "entry", | ||
"corejs": "3.22" | ||
} | ||
], | ||
["@babel/preset-react", { | ||
"runtime": "automatic" | ||
}] | ||
] | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
// import pages | ||
import * as Sentry from '@sentry/browser'; | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import * as Sentry from "@sentry/browser"; | ||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
import '../sass/style.scss'; | ||
import "../sass/style.scss"; | ||
|
||
import App from './App'; | ||
import App from "./App"; | ||
|
||
Sentry.init({ | ||
dsn: window.SENTRY_DSN, | ||
release: window.COMMIT_SHA, | ||
}); | ||
|
||
const root = createRoot(document.getElementById('react-app')); | ||
const root = createRoot(document.getElementById("react-app")); | ||
root.render(<App />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this now instead of babel.config.js. Also, order matters here!