mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-02 10:56:25 -07:00
Replace Gulp with Parcel for js bundling
This commit is contained in:
parent
1848e2f073
commit
d423398eff
10 changed files with 6252 additions and 13436 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,4 +15,5 @@
|
||||||
__debug_bin
|
__debug_bin
|
||||||
node_modules
|
node_modules
|
||||||
/frontend/coverage
|
/frontend/coverage
|
||||||
/frontend/tests/coverage
|
/frontend/tests/coverage
|
||||||
|
.parcel-cache
|
25
build.py
25
build.py
|
@ -33,9 +33,9 @@ release_files = (
|
||||||
"html/hittheroad.mp3",
|
"html/hittheroad.mp3",
|
||||||
"html/hittheroad.ogg",
|
"html/hittheroad.ogg",
|
||||||
"html/hittheroad.wav",
|
"html/hittheroad.wav",
|
||||||
"html/js/maps",
|
"html/js/",
|
||||||
"html/js/maps/gochan.js.map",
|
|
||||||
"html/js/gochan.js",
|
"html/js/gochan.js",
|
||||||
|
"html/js/gochan.js.map",
|
||||||
"html/notbanned.png",
|
"html/notbanned.png",
|
||||||
"html/permabanned.jpg",
|
"html/permabanned.jpg",
|
||||||
"sample-configs",
|
"sample-configs",
|
||||||
|
@ -234,7 +234,7 @@ def install(prefix="/usr", document_root="/srv/gochan", js_only=False, css_only=
|
||||||
if path.exists(js_install_dir) is False:
|
if path.exists(js_install_dir) is False:
|
||||||
fs_action("mkdir", js_install_dir)
|
fs_action("mkdir", js_install_dir)
|
||||||
fs_action("copy", "html/js/gochan.js", path.join(js_install_dir, "gochan.js"))
|
fs_action("copy", "html/js/gochan.js", path.join(js_install_dir, "gochan.js"))
|
||||||
fs_action("copy", "html/js/maps", path.join(js_install_dir, "maps"))
|
fs_action("copy", "html/js/gochan.js.map", path.join(js_install_dir, "gochan.js.map"))
|
||||||
done = True
|
done = True
|
||||||
if css_only:
|
if css_only:
|
||||||
print("Installing gochan CSS files")
|
print("Installing gochan CSS files")
|
||||||
|
@ -293,13 +293,16 @@ def install(prefix="/usr", document_root="/srv/gochan", js_only=False, css_only=
|
||||||
"systemctl start gochan.service")
|
"systemctl start gochan.service")
|
||||||
|
|
||||||
|
|
||||||
def js(nominify=False, watch=False):
|
def js(watch=False):
|
||||||
print("Transpiling JS")
|
print("Transpiling JS")
|
||||||
npm_cmd = "npm --prefix frontend/ run build"
|
fs_action("mkdir", "html/js/")
|
||||||
if nominify is False:
|
fs_action("delete", "html/js/gochan.js")
|
||||||
npm_cmd += "-minify"
|
fs_action("delete", "html/js/gochan.js.map")
|
||||||
|
npm_cmd = "npm --prefix frontend/ run"
|
||||||
if watch:
|
if watch:
|
||||||
npm_cmd += "-watch"
|
npm_cmd += " watch"
|
||||||
|
else:
|
||||||
|
npm_cmd += " build"
|
||||||
|
|
||||||
status = run_cmd(npm_cmd, True, True, True)[1]
|
status = run_cmd(npm_cmd, True, True, True)[1]
|
||||||
if status != 0:
|
if status != 0:
|
||||||
|
@ -412,16 +415,12 @@ if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
install(args.prefix, args.documentroot, args.js, args.css, args.templates)
|
install(args.prefix, args.documentroot, args.js, args.css, args.templates)
|
||||||
elif action == "js":
|
elif action == "js":
|
||||||
parser.add_argument(
|
|
||||||
"--nominify",
|
|
||||||
action="store_true",
|
|
||||||
help="Don't minify gochan.js")
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--watch",
|
"--watch",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="automatically rebuild when you change a file (keeps running)")
|
help="automatically rebuild when you change a file (keeps running)")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
js(args.nominify, args.watch)
|
js(args.watch)
|
||||||
elif action == "release":
|
elif action == "release":
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--all",
|
"--all",
|
||||||
|
|
9
frontend/.parcelrc
Normal file
9
frontend/.parcelrc
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
// this is here since parcel and babel don't seem to get along
|
||||||
|
"extends": "@parcel/config-default",
|
||||||
|
"transformers": {
|
||||||
|
"*.js": [
|
||||||
|
"@parcel/transformer-js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,50 +0,0 @@
|
||||||
import browserify from "browserify";
|
|
||||||
import buffer from "vinyl-buffer"
|
|
||||||
import fancy_log from "fancy-log";
|
|
||||||
import glob from "glob";
|
|
||||||
import gulp from "gulp";
|
|
||||||
import stdio from "stdio";
|
|
||||||
import uglify from "gulp-uglify";
|
|
||||||
import source from "vinyl-source-stream";
|
|
||||||
import watchify from "watchify";
|
|
||||||
import sourcemaps from 'gulp-sourcemaps';
|
|
||||||
|
|
||||||
const args = stdio.getopt({
|
|
||||||
"watch": {key: "w", description: "Automatically rebuild when you change a file"},
|
|
||||||
"minify": {key: "m", description: "minify generated gochan.js"}
|
|
||||||
});
|
|
||||||
|
|
||||||
let builder = browserify({
|
|
||||||
entries: glob.sync("src/**/*.js")
|
|
||||||
});
|
|
||||||
|
|
||||||
function buildTask(minify) {
|
|
||||||
fancy_log("Building gochan frontend");
|
|
||||||
let babelOptions = {
|
|
||||||
presets: ["@babel/preset-env"],
|
|
||||||
comments: false
|
|
||||||
}
|
|
||||||
|
|
||||||
let out = builder.transform("babelify", babelOptions)
|
|
||||||
.bundle()
|
|
||||||
.pipe(source("gochan.js"))
|
|
||||||
.pipe(buffer())
|
|
||||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
|
||||||
|
|
||||||
if(minify)
|
|
||||||
out = out.pipe(uglify());
|
|
||||||
|
|
||||||
return out
|
|
||||||
.pipe(sourcemaps.write('./maps/'))
|
|
||||||
.pipe(gulp.dest("../html/js/", {overwrite: true}));
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task("default", () => {
|
|
||||||
if(args.watch) {
|
|
||||||
builder = watchify(builder);
|
|
||||||
builder.on("update", () => {
|
|
||||||
return buildTask(args.minify)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return buildTask(args.minify);
|
|
||||||
});
|
|
19373
frontend/package-lock.json
generated
19373
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,46 +1,37 @@
|
||||||
{
|
{
|
||||||
"name": "gochan.js",
|
"name": "gochan.js",
|
||||||
"version": "2.11.1",
|
"version": "3.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"type": "module",
|
||||||
"scripts": {
|
"source": "src/gochan.js",
|
||||||
"test": "jest --verbose",
|
"main": "../html/js/gochan.js",
|
||||||
"build": "gulp",
|
"targets": {
|
||||||
"build-minify": "gulp -m",
|
"frontend": {
|
||||||
"build-watch": "gulp -w",
|
"source": "src/gochan.js",
|
||||||
"build-minify-watch": "gulp -m -w"
|
"distDir": "../html/js/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "parcel build --no-cache",
|
||||||
|
"watch": "parcel watch",
|
||||||
|
"test": "jest --verbose"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
|
||||||
"author": "Eggbertx",
|
"author": "Eggbertx",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.20.1",
|
|
||||||
"gulp-sourcemaps": "^2.6.5",
|
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"jqueryui": "^1.11.1",
|
"jqueryui": "^1.11.1"
|
||||||
"regenerator-runtime": "^0.13.9"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.10.1",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@babel/core": "^7.10.2",
|
|
||||||
"@babel/preset-env": "^7.10.2",
|
|
||||||
"@babel/register": "^7.10.1",
|
|
||||||
"@jest/globals": "^27.4.6",
|
"@jest/globals": "^27.4.6",
|
||||||
"@types/jquery": "^3.3.38",
|
"@types/jquery": "^3.3.38",
|
||||||
"@types/jqueryui": "^1.12.13",
|
"@types/jqueryui": "^1.12.13",
|
||||||
"babel-jest": "^27.4.6",
|
"babel-jest": "^27.5.1",
|
||||||
"babelify": "^10.0.0",
|
|
||||||
"browserify": "^16.5.0",
|
|
||||||
"fancy-log": "^1.3.3",
|
|
||||||
"gulp": "^4.0.2",
|
|
||||||
"gulp-babel": "^8.0.0",
|
|
||||||
"gulp-uglify": "^3.0.2",
|
|
||||||
"jest": "^27.4.7",
|
"jest": "^27.4.7",
|
||||||
"regenerator-runtime": "^0.13.9",
|
"parcel": "^2.4.0",
|
||||||
"stdio": "^0.2.7",
|
|
||||||
"vinyl-buffer": "^1.0.1",
|
|
||||||
"vinyl-source-stream": "^2.0.0",
|
|
||||||
"watchify": "^4.0.0",
|
|
||||||
"yargs-parser": ">=5.0.0-security.0"
|
"yargs-parser": ">=5.0.0-security.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
// needed for Promise stuff
|
|
||||||
import "core-js/stable";
|
|
||||||
import "regenerator-runtime/runtime";
|
|
||||||
|
|
||||||
import { handleActions, handleKeydown } from "./boardevents";
|
import { handleActions, handleKeydown } from "./boardevents";
|
||||||
import { initCookies, getCookie } from "./cookies";
|
import { initCookies, getCookie } from "./cookies";
|
||||||
import { initStaff, createStaffMenu } from "./manage";
|
import { initStaff, createStaffMenu } from "./manage";
|
File diff suppressed because one or more lines are too long
1
html/js/gochan.js.map
Normal file
1
html/js/gochan.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue