Init Vue + Webpack
This commit is contained in:
@@ -14,6 +14,8 @@ import os
|
|||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
|
||||||
|
FRONTEND_DIR = os.path.join(BASE_DIR, 'frontend')
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
@@ -37,6 +39,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'webpack_loader',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -54,7 +57,7 @@ ROOT_URLCONF = 'cookAssistant.urls'
|
|||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [TEMPLATES_DIR, ],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
@@ -118,3 +121,11 @@ USE_TZ = True
|
|||||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
WEBPACK_LOADER = {
|
||||||
|
'DEFAULT': {
|
||||||
|
'CACHE': not DEBUG,
|
||||||
|
'BUNDLE_DIR_NAME': '/bundles/', # must end with slash
|
||||||
|
'STATS_FILE': os.path.join(FRONTEND_DIR, 'webpack-stats.json'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('',
|
||||||
|
TemplateView.as_view(
|
||||||
|
template_name="application.html"
|
||||||
|
),
|
||||||
|
name="app"
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
21
frontend/.gitignore
vendored
Normal file
21
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
/dist
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
# Log files
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw*
|
||||||
29
frontend/README.md
Normal file
29
frontend/README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# frontend
|
||||||
|
|
||||||
|
## Project setup
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiles and hot-reloads for development
|
||||||
|
```
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiles and minifies for production
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run your tests
|
||||||
|
```
|
||||||
|
npm run test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lints and fixes files
|
||||||
|
```
|
||||||
|
npm run lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customize configuration
|
||||||
|
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||||
5
frontend/babel.config.js
Normal file
5
frontend/babel.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
'@vue/app'
|
||||||
|
]
|
||||||
|
}
|
||||||
11308
frontend/package-lock.json
generated
Normal file
11308
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
53
frontend/package.json
Normal file
53
frontend/package.json
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"serve": "vue-cli-service serve",
|
||||||
|
"build": "vue-cli-service build",
|
||||||
|
"lint": "vue-cli-service lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"core-js": "^2.6.5",
|
||||||
|
"vue": "^2.6.6",
|
||||||
|
"vuetify": "^1.5.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vue/cli-plugin-babel": "^3.5.0",
|
||||||
|
"@vue/cli-plugin-eslint": "^3.5.0",
|
||||||
|
"@vue/cli-service": "^3.5.0",
|
||||||
|
"babel-eslint": "^10.0.1",
|
||||||
|
"eslint": "^5.8.0",
|
||||||
|
"eslint-plugin-vue": "^5.0.0",
|
||||||
|
"stylus": "^0.54.5",
|
||||||
|
"stylus-loader": "^3.0.1",
|
||||||
|
"vue-cli-plugin-vuetify": "^0.5.0",
|
||||||
|
"vue-template-compiler": "^2.5.21",
|
||||||
|
"vuetify-loader": "^1.0.5",
|
||||||
|
"webpack-bundle-tracker": "^0.4.2-beta"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"root": true,
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"plugin:vue/essential",
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"rules": {},
|
||||||
|
"parserOptions": {
|
||||||
|
"parser": "babel-eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postcss": {
|
||||||
|
"plugins": {
|
||||||
|
"autoprefixer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"> 1%",
|
||||||
|
"last 2 versions",
|
||||||
|
"not ie <= 8"
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
frontend/public/favicon.ico
Normal file
BIN
frontend/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
19
frontend/public/index.html
Normal file
19
frontend/public/index.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
|
<title>frontend</title>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
|
</noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
frontend/src/App.vue
Normal file
27
frontend/src/App.vue
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<v-app>
|
||||||
|
<ToolBar/>
|
||||||
|
|
||||||
|
<v-content>
|
||||||
|
<HelloWorld/>
|
||||||
|
</v-content>
|
||||||
|
</v-app>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HelloWorld from './components/HelloWorld'
|
||||||
|
import ToolBar from './components/ToolBar'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'App',
|
||||||
|
components: {
|
||||||
|
HelloWorld,
|
||||||
|
ToolBar
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
BIN
frontend/src/assets/logo.png
Normal file
BIN
frontend/src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
1
frontend/src/assets/logo.svg
Normal file
1
frontend/src/assets/logo.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>
|
||||||
|
After Width: | Height: | Size: 539 B |
147
frontend/src/components/HelloWorld.vue
Normal file
147
frontend/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<v-layout
|
||||||
|
text-xs-center
|
||||||
|
wrap
|
||||||
|
>
|
||||||
|
<v-flex xs12>
|
||||||
|
<v-img
|
||||||
|
:src="require('../assets/logo.svg')"
|
||||||
|
class="my-3"
|
||||||
|
contain
|
||||||
|
height="200"
|
||||||
|
></v-img>
|
||||||
|
</v-flex>
|
||||||
|
|
||||||
|
<v-flex mb-4>
|
||||||
|
<h1 class="display-2 font-weight-bold mb-3">
|
||||||
|
Welcome to Vuetify
|
||||||
|
</h1>
|
||||||
|
<p class="subheading font-weight-regular">
|
||||||
|
For help and collaboration with other Vuetify developers,
|
||||||
|
<br>please join our online
|
||||||
|
<a href="https://community.vuetifyjs.com" target="_blank">Discord Community</a>
|
||||||
|
</p>
|
||||||
|
</v-flex>
|
||||||
|
|
||||||
|
<v-flex
|
||||||
|
mb-5
|
||||||
|
xs12
|
||||||
|
>
|
||||||
|
<h2 class="headline font-weight-bold mb-3">What's next?</h2>
|
||||||
|
|
||||||
|
<v-layout justify-center>
|
||||||
|
<a
|
||||||
|
v-for="(next, i) in whatsNext"
|
||||||
|
:key="i"
|
||||||
|
:href="next.href"
|
||||||
|
class="subheading mx-3"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ next.text }}
|
||||||
|
</a>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
|
||||||
|
<v-flex
|
||||||
|
xs12
|
||||||
|
mb-5
|
||||||
|
>
|
||||||
|
<h2 class="headline font-weight-bold mb-3">Important Links</h2>
|
||||||
|
|
||||||
|
<v-layout justify-center>
|
||||||
|
<a
|
||||||
|
v-for="(link, i) in importantLinks"
|
||||||
|
:key="i"
|
||||||
|
:href="link.href"
|
||||||
|
class="subheading mx-3"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ link.text }}
|
||||||
|
</a>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
|
||||||
|
<v-flex
|
||||||
|
xs12
|
||||||
|
mb-5
|
||||||
|
>
|
||||||
|
<h2 class="headline font-weight-bold mb-3">Ecosystem</h2>
|
||||||
|
|
||||||
|
<v-layout justify-center>
|
||||||
|
<a
|
||||||
|
v-for="(eco, i) in ecosystem"
|
||||||
|
:key="i"
|
||||||
|
:href="eco.href"
|
||||||
|
class="subheading mx-3"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ eco.text }}
|
||||||
|
</a>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data: () => ({
|
||||||
|
ecosystem: [
|
||||||
|
{
|
||||||
|
text: 'vuetify-loader',
|
||||||
|
href: 'https://github.com/vuetifyjs/vuetify-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'github',
|
||||||
|
href: 'https://github.com/vuetifyjs/vuetify'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'awesome-vuetify',
|
||||||
|
href: 'https://github.com/vuetifyjs/awesome-vuetify'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
importantLinks: [
|
||||||
|
{
|
||||||
|
text: 'Documentation',
|
||||||
|
href: 'https://vuetifyjs.com'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Chat',
|
||||||
|
href: 'https://community.vuetifyjs.com'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Made with Vuetify',
|
||||||
|
href: 'https://madewithvuetifyjs.com'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Twitter',
|
||||||
|
href: 'https://twitter.com/vuetifyjs'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Articles',
|
||||||
|
href: 'https://medium.com/vuetify'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
whatsNext: [
|
||||||
|
{
|
||||||
|
text: 'Explore components',
|
||||||
|
href: 'https://vuetifyjs.com/components/api-explorer'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Select a layout',
|
||||||
|
href: 'https://vuetifyjs.com/layout/pre-defined'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Frequently Asked Questions',
|
||||||
|
href: 'https://vuetifyjs.com/getting-started/frequently-asked-questions'
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
37
frontend/src/components/ToolBar.vue
Normal file
37
frontend/src/components/ToolBar.vue
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<v-toolbar dark color="primary">
|
||||||
|
<!-- <v-toolbar-side-icon></v-toolbar-side-icon> -->
|
||||||
|
|
||||||
|
<v-toolbar-title class="white--text">
|
||||||
|
Cook Assistant
|
||||||
|
</v-toolbar-title>
|
||||||
|
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
|
||||||
|
<v-btn icon>
|
||||||
|
<v-icon>search</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn icon>
|
||||||
|
<v-icon>apps</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn icon>
|
||||||
|
<v-icon>refresh</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn icon>
|
||||||
|
<v-icon>more_vert</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-toolbar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data: () => ({})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
9
frontend/src/main.js
Normal file
9
frontend/src/main.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import './plugins/vuetify'
|
||||||
|
import App from './App.vue'
|
||||||
|
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
render: h => h(App),
|
||||||
|
}).$mount('#app')
|
||||||
7
frontend/src/plugins/vuetify.js
Normal file
7
frontend/src/plugins/vuetify.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import Vuetify from 'vuetify/lib'
|
||||||
|
import 'vuetify/src/stylus/app.styl'
|
||||||
|
|
||||||
|
Vue.use(Vuetify, {
|
||||||
|
iconfont: 'md',
|
||||||
|
})
|
||||||
30
frontend/vue.config.js
Normal file
30
frontend/vue.config.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
const BundleTracker = require("webpack-bundle-tracker");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
baseUrl: "http://127.0.0.1:8080/",
|
||||||
|
outputDir: './dist/',
|
||||||
|
|
||||||
|
chainWebpack: config => {
|
||||||
|
|
||||||
|
config.optimization
|
||||||
|
.splitChunks(false)
|
||||||
|
|
||||||
|
config
|
||||||
|
.plugin('BundleTracker')
|
||||||
|
.use(BundleTracker, [{filename: '../frontend/webpack-stats.json'}])
|
||||||
|
|
||||||
|
config.resolve.alias
|
||||||
|
.set('__STATIC__', 'static')
|
||||||
|
|
||||||
|
config.devServer
|
||||||
|
.public('http://0.0.0.0:8080')
|
||||||
|
.host('0.0.0.0')
|
||||||
|
.port(8080)
|
||||||
|
.hotOnly(true)
|
||||||
|
.watchOptions({poll: 1000})
|
||||||
|
.https(false)
|
||||||
|
.headers(
|
||||||
|
{"Access-Control-Allow-Origin": ["\*"]}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
1
frontend/webpack-stats.json
Normal file
1
frontend/webpack-stats.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"status":"done","publicPath":"http://127.0.0.1:8080/","chunks":{"app":[{"name":"app.js","publicPath":"http://127.0.0.1:8080/app.js","path":"C:\\Users\\lecor\\Documents\\Dev\\Python\\cookAssistant\\frontend\\dist\\app.js"},{"name":"app.a2bf8f46c2ce5a8648c5.hot-update.js","publicPath":"http://127.0.0.1:8080/app.a2bf8f46c2ce5a8648c5.hot-update.js","path":"C:\\Users\\lecor\\Documents\\Dev\\Python\\cookAssistant\\frontend\\dist\\app.a2bf8f46c2ce5a8648c5.hot-update.js"}]},"error":"ModuleError","message":"Module Error (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):\n(Emitted value instead of an instance of Error) \n\n Errors compiling template:\n\n tag <v-toolbar-items> has no matching end tag.\n\n 7 | </v-toolbar-title>\n 8 | <v-spacer></v-spacer>\n 9 | <v-toolbar-items>\n | ^^^^^^^^^^^^^^^^^\n 10 | <v-btn\n 11 | flat\n"}
|
||||||
@@ -1 +1,2 @@
|
|||||||
django
|
django==2.2
|
||||||
|
django-webpack-loader==0.6
|
||||||
|
|||||||
27
templates/application.html
Normal file
27
templates/application.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{% load render_bundle from webpack_loader %}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<title>Django Vue Integration</title>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<div id="app">
|
||||||
|
<app></app>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% render_bundle 'app' %}
|
||||||
|
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user