Init
This commit is contained in:
commit
14c75db7dd
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/.venv
|
||||||
|
/.virtualenv/
|
||||||
|
/dist/
|
||||||
|
/lib/*
|
||||||
|
!/lib/.keep
|
||||||
|
/node_modules/
|
||||||
|
/static/
|
||||||
|
/templates/
|
||||||
|
/venv/
|
||||||
|
/run/*
|
||||||
|
!/run/.keep
|
||||||
|
__pycache__/
|
||||||
|
*.vimsession
|
60
app.py
Normal file
60
app.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, jsonify, Blueprint, url_for, render_template
|
||||||
|
from flask_restx import Resource, Api, fields
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
from flask_migrate import Migrate
|
||||||
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
|
||||||
|
#class Base(DeclarativeBase):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
print(dir_path)
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config["SQLALCHEMY_DATABASE_URI"] = (
|
||||||
|
"mysql://user:password@localhost/database?unix_socket="
|
||||||
|
+ dir_path
|
||||||
|
+ "/run/mysqld.sock"
|
||||||
|
)
|
||||||
|
#db.init_app(app)
|
||||||
|
|
||||||
|
blueprint = Blueprint('api', __name__, url_prefix='/api')
|
||||||
|
api = Api(blueprint, doc='/doc/')
|
||||||
|
|
||||||
|
app.register_blueprint(blueprint)
|
||||||
|
|
||||||
|
#assert url_for('api.doc') == '/api/doc/'
|
||||||
|
|
||||||
|
|
||||||
|
db = SQLAlchemy(app)
|
||||||
|
migrate = Migrate(app, db)
|
||||||
|
|
||||||
|
#api = Api(app)
|
||||||
|
|
||||||
|
parent = api.model('Parent', {
|
||||||
|
'name': fields.String,
|
||||||
|
'class': fields.String(discriminator=True)
|
||||||
|
})
|
||||||
|
|
||||||
|
class UserModel(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
name = db.Column(db.String(128))
|
||||||
|
|
||||||
|
class TagModel(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
name = db.Column(db.String(128))
|
||||||
|
|
||||||
|
@api.route('/hello', endpoint='tag')
|
||||||
|
class HelloWorld(Resource):
|
||||||
|
def get(self):
|
||||||
|
return {'hello': 'fooobarchangedresult'}
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def hello():
|
||||||
|
return render_template('index.html')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
version: '3'
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:5.5
|
||||||
|
user: 1000:1000
|
||||||
|
command: mysqld --character-set-server=utf8 --collation-server=utf8_bin
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
MYSQL_DATABASE: database
|
||||||
|
MYSQL_USER: user
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
volumes:
|
||||||
|
- ./lib:/var/lib/mysql
|
||||||
|
# - data:/var/lib/mysql
|
||||||
|
# - ./db:/data
|
||||||
|
- ./run:/var/run/mysqld
|
||||||
|
#ports:
|
||||||
|
# - 8306:3306
|
1
migrations/README
Normal file
1
migrations/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
Single-database configuration for Flask.
|
50
migrations/alembic.ini
Normal file
50
migrations/alembic.ini
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# A generic, single database configuration.
|
||||||
|
|
||||||
|
[alembic]
|
||||||
|
# template used to generate migration files
|
||||||
|
# file_template = %%(rev)s_%%(slug)s
|
||||||
|
|
||||||
|
# set to 'true' to run the environment during
|
||||||
|
# the 'revision' command, regardless of autogenerate
|
||||||
|
# revision_environment = false
|
||||||
|
|
||||||
|
|
||||||
|
# Logging configuration
|
||||||
|
[loggers]
|
||||||
|
keys = root,sqlalchemy,alembic,flask_migrate
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys = console
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys = generic
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level = WARN
|
||||||
|
handlers = console
|
||||||
|
qualname =
|
||||||
|
|
||||||
|
[logger_sqlalchemy]
|
||||||
|
level = WARN
|
||||||
|
handlers =
|
||||||
|
qualname = sqlalchemy.engine
|
||||||
|
|
||||||
|
[logger_alembic]
|
||||||
|
level = INFO
|
||||||
|
handlers =
|
||||||
|
qualname = alembic
|
||||||
|
|
||||||
|
[logger_flask_migrate]
|
||||||
|
level = INFO
|
||||||
|
handlers =
|
||||||
|
qualname = flask_migrate
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class = StreamHandler
|
||||||
|
args = (sys.stderr,)
|
||||||
|
level = NOTSET
|
||||||
|
formatter = generic
|
||||||
|
|
||||||
|
[formatter_generic]
|
||||||
|
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||||
|
datefmt = %H:%M:%S
|
113
migrations/env.py
Normal file
113
migrations/env.py
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
import logging
|
||||||
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
|
||||||
|
# this is the Alembic Config object, which provides
|
||||||
|
# access to the values within the .ini file in use.
|
||||||
|
config = context.config
|
||||||
|
|
||||||
|
# Interpret the config file for Python logging.
|
||||||
|
# This line sets up loggers basically.
|
||||||
|
fileConfig(config.config_file_name)
|
||||||
|
logger = logging.getLogger('alembic.env')
|
||||||
|
|
||||||
|
|
||||||
|
def get_engine():
|
||||||
|
try:
|
||||||
|
# this works with Flask-SQLAlchemy<3 and Alchemical
|
||||||
|
return current_app.extensions['migrate'].db.get_engine()
|
||||||
|
except (TypeError, AttributeError):
|
||||||
|
# this works with Flask-SQLAlchemy>=3
|
||||||
|
return current_app.extensions['migrate'].db.engine
|
||||||
|
|
||||||
|
|
||||||
|
def get_engine_url():
|
||||||
|
try:
|
||||||
|
return get_engine().url.render_as_string(hide_password=False).replace(
|
||||||
|
'%', '%%')
|
||||||
|
except AttributeError:
|
||||||
|
return str(get_engine().url).replace('%', '%%')
|
||||||
|
|
||||||
|
|
||||||
|
# add your model's MetaData object here
|
||||||
|
# for 'autogenerate' support
|
||||||
|
# from myapp import mymodel
|
||||||
|
# target_metadata = mymodel.Base.metadata
|
||||||
|
config.set_main_option('sqlalchemy.url', get_engine_url())
|
||||||
|
target_db = current_app.extensions['migrate'].db
|
||||||
|
|
||||||
|
# other values from the config, defined by the needs of env.py,
|
||||||
|
# can be acquired:
|
||||||
|
# my_important_option = config.get_main_option("my_important_option")
|
||||||
|
# ... etc.
|
||||||
|
|
||||||
|
|
||||||
|
def get_metadata():
|
||||||
|
if hasattr(target_db, 'metadatas'):
|
||||||
|
return target_db.metadatas[None]
|
||||||
|
return target_db.metadata
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_offline():
|
||||||
|
"""Run migrations in 'offline' mode.
|
||||||
|
|
||||||
|
This configures the context with just a URL
|
||||||
|
and not an Engine, though an Engine is acceptable
|
||||||
|
here as well. By skipping the Engine creation
|
||||||
|
we don't even need a DBAPI to be available.
|
||||||
|
|
||||||
|
Calls to context.execute() here emit the given string to the
|
||||||
|
script output.
|
||||||
|
|
||||||
|
"""
|
||||||
|
url = config.get_main_option("sqlalchemy.url")
|
||||||
|
context.configure(
|
||||||
|
url=url, target_metadata=get_metadata(), literal_binds=True
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_online():
|
||||||
|
"""Run migrations in 'online' mode.
|
||||||
|
|
||||||
|
In this scenario we need to create an Engine
|
||||||
|
and associate a connection with the context.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# this callback is used to prevent an auto-migration from being generated
|
||||||
|
# when there are no changes to the schema
|
||||||
|
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
|
||||||
|
def process_revision_directives(context, revision, directives):
|
||||||
|
if getattr(config.cmd_opts, 'autogenerate', False):
|
||||||
|
script = directives[0]
|
||||||
|
if script.upgrade_ops.is_empty():
|
||||||
|
directives[:] = []
|
||||||
|
logger.info('No changes in schema detected.')
|
||||||
|
|
||||||
|
conf_args = current_app.extensions['migrate'].configure_args
|
||||||
|
if conf_args.get("process_revision_directives") is None:
|
||||||
|
conf_args["process_revision_directives"] = process_revision_directives
|
||||||
|
|
||||||
|
connectable = get_engine()
|
||||||
|
|
||||||
|
with connectable.connect() as connection:
|
||||||
|
context.configure(
|
||||||
|
connection=connection,
|
||||||
|
target_metadata=get_metadata(),
|
||||||
|
**conf_args
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
if context.is_offline_mode():
|
||||||
|
run_migrations_offline()
|
||||||
|
else:
|
||||||
|
run_migrations_online()
|
24
migrations/script.py.mako
Normal file
24
migrations/script.py.mako
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""${message}
|
||||||
|
|
||||||
|
Revision ID: ${up_revision}
|
||||||
|
Revises: ${down_revision | comma,n}
|
||||||
|
Create Date: ${create_date}
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
${imports if imports else ""}
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = ${repr(up_revision)}
|
||||||
|
down_revision = ${repr(down_revision)}
|
||||||
|
branch_labels = ${repr(branch_labels)}
|
||||||
|
depends_on = ${repr(depends_on)}
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
${downgrades if downgrades else "pass"}
|
32
migrations/versions/3be96cae3b6b_.py
Normal file
32
migrations/versions/3be96cae3b6b_.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 3be96cae3b6b
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-02-28 23:48:14.852119
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '3be96cae3b6b'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('user',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=128), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('user')
|
||||||
|
# ### end Alembic commands ###
|
47
migrations/versions/79778b94f532_add_tag_model.py
Normal file
47
migrations/versions/79778b94f532_add_tag_model.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
"""Add tag model
|
||||||
|
|
||||||
|
Revision ID: 79778b94f532
|
||||||
|
Revises: 3be96cae3b6b
|
||||||
|
Create Date: 2024-03-11 23:44:01.820037
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '79778b94f532'
|
||||||
|
down_revision = '3be96cae3b6b'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('tag_model',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=128), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('user_model',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=128), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.drop_table('user')
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('user',
|
||||||
|
sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
|
||||||
|
sa.Column('name', mysql.VARCHAR(collation='utf8_bin', length=128), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
mysql_collate='utf8_bin',
|
||||||
|
mysql_default_charset='utf8',
|
||||||
|
mysql_engine='InnoDB'
|
||||||
|
)
|
||||||
|
op.drop_table('user_model')
|
||||||
|
op.drop_table('tag_model')
|
||||||
|
# ### end Alembic commands ###
|
6086
package-lock.json
generated
Normal file
6086
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
52
package.json
Normal file
52
package.json
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"name": "snippetlib",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --config webpack.config.js --env production",
|
||||||
|
"dev:build": "webpack --config webpack.config.js --env dev",
|
||||||
|
"dev:watch": "webpack serve --config webpack.config.js --env dev",
|
||||||
|
"dev:serve": "nodemon --watch webpack.config.js --exec 'node --max_old_space_size=8192 node_modules/.bin/webpack serve --config webpack.config.js --env dev'",
|
||||||
|
"dev:serve:termlog": "nodemon --watch webpack.config.js --exec 'node --max_old_space_size=8192 node_modules/.bin/webpack serve --config webpack.config.js --env dev --env termlog'"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@git.datentonne.net:snippetlib/server.git"
|
||||||
|
},
|
||||||
|
"author": "Philipp Dieter <philipp.dieter@attic-media.net>",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"devDependencies": {
|
||||||
|
"bulma": "^1.0.1",
|
||||||
|
"coffee-loader": "^5.0.0",
|
||||||
|
"coffeescript": "^2.7.0",
|
||||||
|
"css-loader": "^7.1.2",
|
||||||
|
"ejs-loader-compiled": "github:yetzt/ejs-loader-compiled",
|
||||||
|
"ejs-pug-vue-resource-loader": "github:cjel/ejs-pug-vue-resource-loader",
|
||||||
|
"html-loader": "^5.0.0",
|
||||||
|
"html-webpack-plugin": "^5.6.0",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"mini-css-extract-plugin": "^2.9.0",
|
||||||
|
"node-sass-glob-importer": "^3.0.2",
|
||||||
|
"nodemon": "^3.1.3",
|
||||||
|
"pug": "^3.0.3",
|
||||||
|
"pug-plain-loader": "github:philippdieter/pug-plain-loader",
|
||||||
|
"sass": "^1.77.4",
|
||||||
|
"sass-loader": "^14.2.1",
|
||||||
|
"style-loader": "^4.0.0",
|
||||||
|
"vue": "~3.2",
|
||||||
|
"vue-component-merge-loader": "github:cjel/vue-component-merge-loader",
|
||||||
|
"vue-loader": "^17.4.2",
|
||||||
|
"vue-style-loader": "^4.1.3",
|
||||||
|
"vue-template-compiler": "^2.7.16",
|
||||||
|
"webpack": "^5.91.0",
|
||||||
|
"webpack-build-notifier": "^3.1.0",
|
||||||
|
"webpack-cli": "^5.1.4",
|
||||||
|
"webpack-config-helpers": "github:cjel/webpack-config-helpers",
|
||||||
|
"webpack-dev-server": "^5.0.4",
|
||||||
|
"webpack-force-reload-plugin": "github:cjel/webpack-force-reload-plugin"
|
||||||
|
}
|
||||||
|
}
|
24
requirements.txt
Normal file
24
requirements.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
alembic==1.13.1
|
||||||
|
aniso8601==9.0.1
|
||||||
|
attrs==23.2.0
|
||||||
|
blinker==1.7.0
|
||||||
|
click==8.1.7
|
||||||
|
Flask==3.0.2
|
||||||
|
Flask-Migrate==4.0.7
|
||||||
|
flask-restx==1.3.0
|
||||||
|
Flask-SQLAlchemy==3.1.1
|
||||||
|
greenlet==3.0.3
|
||||||
|
importlib_resources==6.1.2
|
||||||
|
itsdangerous==2.1.2
|
||||||
|
Jinja2==3.1.3
|
||||||
|
jsonschema==4.21.1
|
||||||
|
jsonschema-specifications==2023.12.1
|
||||||
|
Mako==1.3.5
|
||||||
|
MarkupSafe==2.1.5
|
||||||
|
mysqlclient==2.2.4
|
||||||
|
pytz==2024.1
|
||||||
|
referencing==0.33.0
|
||||||
|
rpds-py==0.18.0
|
||||||
|
SQLAlchemy==2.0.27
|
||||||
|
typing_extensions==4.10.0
|
||||||
|
Werkzeug==3.0.1
|
23
src/components/test2.vue
Normal file
23
src/components/test2.vue
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<script lang="coffee">
|
||||||
|
export default
|
||||||
|
data:
|
||||||
|
-> {
|
||||||
|
foo: 'bar what? aldkjashdlkjasdsadsadsad'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template lang="pug">
|
||||||
|
.example
|
||||||
|
p line 1
|
||||||
|
p line 2
|
||||||
|
| <%- require('markup-elements/button.pug')({foo: 'buttonnewcontent'}) %>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="sass">
|
||||||
|
$color: yellow
|
||||||
|
html
|
||||||
|
div
|
||||||
|
.example,
|
||||||
|
.button
|
||||||
|
color: $color
|
||||||
|
</style>
|
6
src/markup/actions/test3.vue.pug
Normal file
6
src/markup/actions/test3.vue.pug
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
div
|
||||||
|
h2 test from test3.vue.pug file
|
||||||
|
div
|
||||||
|
| MSGMSGMSGmsg:
|
||||||
|
| {{ msg }}
|
||||||
|
| {{ msg }}
|
7
src/markup/actions/test4.vue.pug
Normal file
7
src/markup/actions/test4.vue.pug
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
div
|
||||||
|
div {{ foo }}
|
||||||
|
div {{ foo }}
|
||||||
|
div {{ foo }}
|
||||||
|
| <%- require('markup-elements/button.pug?{data: { \
|
||||||
|
| title: \'bar\' \
|
||||||
|
| }}')() %>
|
7
src/markup/app.vue.pug
Normal file
7
src/markup/app.vue.pug
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
section.section
|
||||||
|
.container
|
||||||
|
h1.title {{ msg }}
|
||||||
|
test2
|
||||||
|
test3
|
||||||
|
test4
|
||||||
|
//-<%- require('markup-elements/button.pug')({foo: 'asd'}) %>
|
5
src/markup/elements/button.pug
Normal file
5
src/markup/elements/button.pug
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
a.button
|
||||||
|
div
|
||||||
|
div
|
||||||
|
| this is a button
|
||||||
|
div= title
|
8
src/markup/templates/index.pug
Normal file
8
src/markup/templates/index.pug
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
h1 headline
|
||||||
|
|
||||||
|
#app
|
||||||
|
|
||||||
|
div
|
||||||
|
| <%- require('markup-elements/button.pug?{data: { \
|
||||||
|
| title: \'bar\' \
|
||||||
|
| }}')() %>
|
7
src/scripts/actions/test3.vue.js
Normal file
7
src/scripts/actions/test3.vue.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
msg: 'Hello world!'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
5
src/scripts/actions/test4.vue.coffee
Normal file
5
src/scripts/actions/test4.vue.coffee
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export default
|
||||||
|
data:
|
||||||
|
-> {
|
||||||
|
foo: 'asd'
|
||||||
|
}
|
5
src/scripts/app.vue.coffee
Normal file
5
src/scripts/app.vue.coffee
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export default
|
||||||
|
data:
|
||||||
|
-> {
|
||||||
|
msg: 'variable from app.coffee asd'
|
||||||
|
}
|
35
src/scripts/main.js
Normal file
35
src/scripts/main.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import '../styles/app.sass';
|
||||||
|
import { createApp } from 'vue';
|
||||||
|
import app from './app.vue.coffee'
|
||||||
|
import camelCase from "lodash/camelCase";
|
||||||
|
import upperFirst from "lodash/upperFirst";
|
||||||
|
import test2 from '../components/test2.vue'
|
||||||
|
//import test3 from './actions/test3.vue.js'
|
||||||
|
import test4 from './actions/test4.vue.coffee'
|
||||||
|
|
||||||
|
const appInstance = createApp(app);
|
||||||
|
//const appInstance = createApp();
|
||||||
|
appInstance.component('test2', test2);
|
||||||
|
//appInstance.component('test3', test3);
|
||||||
|
appInstance.component('test4', test4);
|
||||||
|
|
||||||
|
//var components = {};
|
||||||
|
//const requireComponent = require.context(
|
||||||
|
// ".",
|
||||||
|
// true,
|
||||||
|
// /^\.\/(?!legacy)[\w\/-]+\/[\w-]+\.vue\.(js|coffee)$/
|
||||||
|
//);
|
||||||
|
//requireComponent.keys().forEach(fileName => {
|
||||||
|
// const componentConfig = requireComponent(fileName);
|
||||||
|
// const componentName = upperFirst(
|
||||||
|
// camelCase(fileName.match(/([^\/]*)\.vue\.(js|coffee)$/)[1])
|
||||||
|
// );
|
||||||
|
// var component = appInstance.component(
|
||||||
|
// componentName,
|
||||||
|
// componentConfig.default || componentConfig
|
||||||
|
// );
|
||||||
|
// components[componentName] = component;
|
||||||
|
//
|
||||||
|
//});
|
||||||
|
|
||||||
|
appInstance.mount('#app');
|
3
src/scripts/moduletest.js
Normal file
3
src/scripts/moduletest.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function printme() {
|
||||||
|
return ('prntme 1');
|
||||||
|
}
|
5
src/styles/app.sass
Normal file
5
src/styles/app.sass
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@charset "utf-8"
|
||||||
|
@import "~bulma/bulma"
|
||||||
|
|
||||||
|
html
|
||||||
|
border: 5px solid green
|
204
webpack.config.js
Normal file
204
webpack.config.js
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
|
||||||
|
const WebpackForceReloadPlugin = require('webpack-force-reload-plugin');
|
||||||
|
const _ = require('lodash');
|
||||||
|
const configHelpers = require('webpack-config-helpers');
|
||||||
|
const globImporter = require('node-sass-glob-importer');
|
||||||
|
const path = require("path");
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const { VueLoaderPlugin } = require('vue-loader');
|
||||||
|
const { glob } = require('glob');
|
||||||
|
|
||||||
|
let globalDevServer = null;
|
||||||
|
|
||||||
|
module.exports = env => {
|
||||||
|
return {
|
||||||
|
mode: configHelpers.ifProduction(env, 'production', 'development'),
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.vue$/,
|
||||||
|
loader: 'vue-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.vue\.(coffee|js)$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'vue-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: 'vue-component-merge-loader',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.coffee$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'coffee-loader',
|
||||||
|
options: {
|
||||||
|
bare: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.pug$/,
|
||||||
|
oneOf: [
|
||||||
|
{
|
||||||
|
resourceQuery: /^\?vue/u,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'ejs-pug-vue-resource-loader',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'ejs-loader-compiled',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: 'pug-plain-loader',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(css)$/,
|
||||||
|
use: [
|
||||||
|
configHelpers.ifNotProduction(
|
||||||
|
env,
|
||||||
|
'vue-style-loader',
|
||||||
|
MiniCssExtractPlugin.loader
|
||||||
|
),
|
||||||
|
{
|
||||||
|
loader: 'css-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sideEffects: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(sass)$/,
|
||||||
|
use: [
|
||||||
|
configHelpers.ifNotProduction(
|
||||||
|
env,
|
||||||
|
'vue-style-loader',
|
||||||
|
MiniCssExtractPlugin.loader
|
||||||
|
),
|
||||||
|
{
|
||||||
|
loader: 'css-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: 'sass-loader',
|
||||||
|
options: {
|
||||||
|
sassOptions: {
|
||||||
|
importer: globImporter(),
|
||||||
|
indentedSyntax: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sideEffects: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
NODE_ENV: configHelpers.ifProduction(
|
||||||
|
env,
|
||||||
|
'"production"',
|
||||||
|
'"development"'
|
||||||
|
),
|
||||||
|
'termlog': env.termlog,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
minify: false,
|
||||||
|
alwaysWriteToDisk: true,
|
||||||
|
template: path.resolve(
|
||||||
|
__dirname,
|
||||||
|
'src',
|
||||||
|
'markup',
|
||||||
|
'templates',
|
||||||
|
'index.pug'
|
||||||
|
),
|
||||||
|
filename: path.resolve(
|
||||||
|
__dirname,
|
||||||
|
'templates',
|
||||||
|
'index.html'
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: 'assets/[name].[contenthash].css',
|
||||||
|
//chunkFilename: '[id].css'
|
||||||
|
}),
|
||||||
|
configHelpers.ifNotProduction(
|
||||||
|
env,
|
||||||
|
new WebpackBuildNotifierPlugin({
|
||||||
|
title: 'Webpack',
|
||||||
|
})
|
||||||
|
),
|
||||||
|
new VueLoaderPlugin(),
|
||||||
|
new WebpackForceReloadPlugin({
|
||||||
|
devServer: function() {
|
||||||
|
return globalDevServer;
|
||||||
|
},
|
||||||
|
cwd: __dirname,
|
||||||
|
files: 'src/markup/templates/**/*'
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
entry: {
|
||||||
|
app: [
|
||||||
|
'./src/scripts/main.js',
|
||||||
|
//'./src/scripts/app.coffee',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: 'assets/[name].[contenthash].js',
|
||||||
|
chunkFilename: 'assets/[name].[contenthash].js',
|
||||||
|
path: path.resolve(__dirname, 'static'),
|
||||||
|
publicPath: '/static/',
|
||||||
|
clean: true,
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'vue$': 'vue/dist/vue.esm-bundler',
|
||||||
|
'markup-elements': path.resolve(__dirname, 'src/markup/elements'),
|
||||||
|
'markup-actions': path.resolve(__dirname, 'src/markup/actions'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
devtool: false,
|
||||||
|
devServer: {
|
||||||
|
setupMiddlewares: (middlewares, devServer) => {
|
||||||
|
globalDevServer = devServer;
|
||||||
|
return middlewares;
|
||||||
|
},
|
||||||
|
port: 3200,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
devMiddleware: {
|
||||||
|
writeToDisk: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all',
|
||||||
|
cacheGroups: {
|
||||||
|
styles: {
|
||||||
|
name: "styles",
|
||||||
|
type: "css/mini-extract",
|
||||||
|
test: /\.css$/,
|
||||||
|
chunks: "all",
|
||||||
|
enforce: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user