Skip to content

Commit

Permalink
- setup webpack
Browse files Browse the repository at this point in the history
- setup docker-compose
- setup django correctly
  • Loading branch information
SteinRobert committed Aug 2, 2019
1 parent b84bb72 commit 5e48312
Show file tree
Hide file tree
Showing 15 changed files with 10,879 additions and 65 deletions.
23 changes: 23 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 2 versions",
"safari >= 7",
"ie >= 8"
]
}
}
]
],
"ignore": [
"node_modules/",
"dist/"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
10 changes: 1 addition & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
FROM node:12.7.0-alpine
RUN mkdir /deps
WORKDIR /deps
COPY package.json /deps
COPY package-lock.json /deps
RUN npm install


FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
COPY . /code/
7 changes: 7 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:12.7.0
RUN mkdir /node_deps
COPY package.json /node_deps/
COPY package-lock.json /node_deps/
WORKDIR /node_deps
RUN npm install
COPY webpack.config.js /node_deps/
30 changes: 13 additions & 17 deletions dll/settings.py → dll/configuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'dll.urls'
ROOT_URLCONF = 'dll.configuration.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand All @@ -68,7 +68,7 @@
},
]

WSGI_APPLICATION = 'dll.wsgi.application'
WSGI_APPLICATION = 'dll.configuration.wsgi.application'


# Database
Expand Down Expand Up @@ -123,26 +123,22 @@

STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]

WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'BUNDLE_DIR_NAME': 'dist/', # must end with slash
'STATS_FILE': os.path.join(BASE_DIR, './static/dist/webpack-stats.json'),
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
'IGNORE': [r'.+\.hot-update.js', r'.+\.map']
}
}

WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'bundles/', # end with slash
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json')
}
}

}
10 changes: 9 additions & 1 deletion dll/urls.py → dll/configuration/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.views.generic import TemplateView


class TestView(TemplateView):
template_name = 'dll/base.html'

urlpatterns = [
path('admin/', admin.site.urls),
]
path('', TestView.as_view())
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
File renamed without changes.
Empty file added dll/static/src/js/index.js
Empty file.
Empty file added dll/static/src/scss/main.scss
Empty file.
1 change: 1 addition & 0 deletions dll/templates/dll/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

</head>
<body>
{% render_bundle 'vendor' 'js' %}
{% render_bundle 'main' 'js' %}
</body>
</html>
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ version: '3'
services:
db:
image: postgres
webpack:
command: npm run start
volumes:
- ./dll/static:/node_deps/static
build:
context: .
dockerfile: Dockerfile.build
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dll.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dll.configuration.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
Loading

0 comments on commit 5e48312

Please sign in to comment.