babeljs integration
This commit is contained in:
parent
fc8834950e
commit
16940e2ccf
9 changed files with 49 additions and 9 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -10,6 +10,11 @@ flask_session/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.venv
|
.venv
|
||||||
*.pyc
|
*.pyc
|
||||||
|
.webassets-cache
|
||||||
|
files/static/gen/
|
||||||
|
|
||||||
|
# nodejs
|
||||||
|
node_modules
|
||||||
|
|
||||||
# rdrama Media Runtime Artifacts
|
# rdrama Media Runtime Artifacts
|
||||||
image.*
|
image.*
|
||||||
|
|
16
Dockerfile
16
Dockerfile
|
@ -1,6 +1,6 @@
|
||||||
###################################################################
|
###################################################################
|
||||||
# Base container
|
# Base container
|
||||||
FROM python:3.10 AS base
|
FROM nikolaik/python-nodejs:python3.10-nodejs20 AS base
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ RUN apt update && apt -y upgrade
|
||||||
WORKDIR /service
|
WORKDIR /service
|
||||||
COPY pyproject.toml .
|
COPY pyproject.toml .
|
||||||
COPY poetry.lock .
|
COPY poetry.lock .
|
||||||
|
COPY package.json .
|
||||||
RUN pip install 'poetry==1.2.2'
|
RUN pip install 'poetry==1.2.2'
|
||||||
RUN poetry config virtualenvs.create false
|
RUN poetry config virtualenvs.create false
|
||||||
|
|
||||||
|
@ -27,14 +28,11 @@ CMD [ "bootstrap/init.sh" ]
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
# Chat compilation framework
|
# Chat compilation framework
|
||||||
ENV NODE_VERSION=16.13.0
|
# We're using an image that comes with node and yarn installed
|
||||||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
|
||||||
ENV NVM_DIRECTORY=/root/.nvm
|
# needed for ES2015 transpilation
|
||||||
RUN . "$NVM_DIRECTORY/nvm.sh" && nvm install ${NODE_VERSION}
|
RUN npm install --global @babel/cli
|
||||||
RUN . "$NVM_DIRECTORY/nvm.sh" && nvm use v${NODE_VERSION}
|
RUN yarn install
|
||||||
RUN . "$NVM_DIRECTORY/nvm.sh" && nvm alias default v${NODE_VERSION}
|
|
||||||
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
|
||||||
RUN npm i -g yarn
|
|
||||||
|
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
|
|
|
@ -25,6 +25,7 @@ import gevent
|
||||||
import redis
|
import redis
|
||||||
from sqlalchemy.engine import Engine, create_engine
|
from sqlalchemy.engine import Engine, create_engine
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
from flask_assets import Environment, Bundle
|
||||||
|
|
||||||
from files.helpers.config.const import Service
|
from files.helpers.config.const import Service
|
||||||
from files.helpers.strings import bool_from_string
|
from files.helpers.strings import bool_from_string
|
||||||
|
@ -39,6 +40,11 @@ app = flask.app.Flask(__name__, template_folder='templates')
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
app.jinja_env.cache = {}
|
app.jinja_env.cache = {}
|
||||||
app.jinja_env.auto_reload = True
|
app.jinja_env.auto_reload = True
|
||||||
|
|
||||||
|
# set up assets
|
||||||
|
assets = Environment(app)
|
||||||
|
assets.from_yaml('files/bundles.yaml')
|
||||||
|
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
|
|
||||||
# ...then check that debug mode was not accidentally enabled...
|
# ...then check that debug mode was not accidentally enabled...
|
||||||
|
|
1
files/assets/js/es/test.js
Normal file
1
files/assets/js/es/test.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
globalThis.TRANSPILED_PACKAGES_WORK = true;
|
1
files/assets/js/es/test2.js
Normal file
1
files/assets/js/es/test2.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
globalThis.MULTIPLE_FILES_WORK = true;
|
7
files/bundles.yaml
Normal file
7
files/bundles.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
es5-bundle:
|
||||||
|
# paths are relative to "files/static"
|
||||||
|
output: gen/es5.js
|
||||||
|
config:
|
||||||
|
BABEL_PRESETS: "@babel/preset-env"
|
||||||
|
filters: babel
|
||||||
|
contents: "../assets/js/es/*.js"
|
|
@ -303,5 +303,9 @@
|
||||||
<script>
|
<script>
|
||||||
MicroModal.init();
|
MicroModal.init();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% assets "es5-bundle" %}
|
||||||
|
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
|
||||||
|
{% endassets %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
16
package.json
Normal file
16
package.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "rdrama",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "[](https://github.com/TheMotte/rDrama/actions?query=workflow%3AE2ETests+branch%3Afrost)",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.23.0",
|
||||||
|
"@babel/core": "^7.23.2",
|
||||||
|
"@babel/preset-env": "^7.23.2"
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,8 @@ webptools = "*"
|
||||||
supervisor = "*"
|
supervisor = "*"
|
||||||
superlance = "*"
|
superlance = "*"
|
||||||
alive-progress = "*"
|
alive-progress = "*"
|
||||||
|
flask-assets = "^2.1.0"
|
||||||
|
pyyaml = "^6.0.1"
|
||||||
|
|
||||||
[tool.poetry.group.dev]
|
[tool.poetry.group.dev]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue