Skip to content

Commit

Permalink
refactor(testapp): Replace bower to esbuild
Browse files Browse the repository at this point in the history
The js build is bundled by esbuild and managed by yarn.

Fixes: #425
  • Loading branch information
piraz committed May 19, 2023
1 parent 85827ca commit 0e04bb9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 30 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ __pycache__

database.sqlite

# Bower
bower_components
# Esbuild/yarn
.yarn
.yarnrc.yml
yarn.lock
node_modules

# C extensions
*.so
Expand Down
24 changes: 0 additions & 24 deletions examples/testapp/bower.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/testapp/conf/firenado.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ components:
#- id: admin
# enabled: true
- id: static_maps
enabled: true
enabled: false
- id: info
enabled: true
- id: toolbox
Expand Down
2 changes: 1 addition & 1 deletion examples/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class UserBase(Base):
created = Column('created', DateTime, nullable=False,
server_default=text('now()'))
modified = Column('modified', DateTime, nullable=False,
server_default=text('now()'))
server_default=text('now()'))
31 changes: 31 additions & 0 deletions examples/testapp/static/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as esbuild from "esbuild"
import { copy } from "esbuild-plugin-copy"
import { entryPoints } from "./entryPoints.mjs"

await esbuild.build({
entryPoints: entryPoints,
bundle: true,
minify: true,
write: true,
treeShaking: true,
sourcemap: true,
logLevel: "info",
outdir: "dist",
legalComments: "none",
allowOverwrite: true,
plugins: [
copy({
assets: [
{
from: ["./node_modules/bootstrap/dist/js/*.min.js"],
to: ["./bootstrap/js"],
},
{
from: ["./node_modules/bootstrap/dist/css/*.min.css"],
to: ["./bootstrap/css"],
},
],
}),
],
})

3 changes: 3 additions & 0 deletions examples/testapp/static/entryPoints.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const entryPoints = [
{ out: "index.js", in: "src/index.js" },
]
24 changes: 24 additions & 0 deletions examples/testapp/static/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "testappjs",
"version": "0.0.1",
"description": "Test App Js Project",
"main": "index.js",
"scripts": {
"esbuild": "rm -rf build && node build.mjs",
"test": "echo \"Error: no test specified\" && exit 1",
"yarn": "npm run yarn:clean && npm run yarn:v2 && npm run yarn:install",
"yarn:install": "yarn install",
"yarn:clean": "rm -rf yarn.lock .yarn .yarnrc.yml .next node_modules",
"yarn:v2": "yarn set version berry && yarn config set nodeLinker node-modules"
},
"author": "Flavio Garcia",
"license": "Apache-2.0",
"dependencies": {
"bootstrap": "5.2.3"
},
"devDependencies": {
"esbuild": "0.17.19",
"esbuild-plugin-copy": "2.1.1"
},
"packageManager": "yarn@3.5.1"
}
Empty file.
4 changes: 2 additions & 2 deletions examples/testapp/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Firenado Test Application</title>

<!-- Bootstrap -->
<link href="{% module RootedPath('/assets/bootstrap/css/bootstrap.min.css') %}" rel="stylesheet">
<link href="{% module RootedPath('/static/dist/bootstrap/css/bootstrap.min.css') %}" rel="stylesheet">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
Expand All @@ -24,7 +24,7 @@
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{% module RootedPath('/assets/jquery/jquery.min.js') %}"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="{% module RootedPath('/assets/bootstrap/js/bootstrap.min.js') %}"></script>
<script src="{% module RootedPath('/static/dist/bootstrap/js/bootstrap.min.js') %}"></script>
<script src="{% module RootedPath('/assets/waypoints/jquery.waypoints.js') %}"></script>
<script src="{% module RootedPath('/assets/waypoints/waypoints.debug.js') %}"></script>
<script language="JavaScript">
Expand Down

0 comments on commit 0e04bb9

Please sign in to comment.