summaryrefslogtreecommitdiff
path: root/web/source/index.js
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2022-11-02 16:31:43 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-02 16:31:43 +0100
commitc4c713988a62c2ca1ea92778f2cebbfd483c98f1 (patch)
tree0e29b53992a452559f221df698fa2e1d5aa1ce1b /web/source/index.js
parent[chore] Bump CI dependencies (#944) (diff)
downloadgotosocial-c4c713988a62c2ca1ea92778f2cebbfd483c98f1.tar.xz
[frontend] change bundler to skulk (#942)
* replace web bundler with skulk * upgrade skulk * add license
Diffstat (limited to 'web/source/index.js')
-rw-r--r--web/source/index.js91
1 files changed, 57 insertions, 34 deletions
diff --git a/web/source/index.js b/web/source/index.js
index 896d2b09a..a96e663cd 100644
--- a/web/source/index.js
+++ b/web/source/index.js
@@ -18,47 +18,70 @@
"use strict";
-/*
- Bundle the PostCSS stylesheets and javascript bundles for general frontend and settings panel
-*/
-
-const path = require('path');
-const fsSync = require("fs");
-const chalk = require("chalk");
-
-const gtsBundler = require("./lib/bundler");
+const skulk = require("skulk");
+const fs = require("fs");
+const path = require("path");
-const devMode = process.env.NODE_ENV == "development";
-if (devMode) {
- console.log(chalk.yellow("GoToSocial web asset bundler, running in development mode"));
-} else {
- console.log(chalk.yellow("GoToSocial web asset bundler, creating production build"));
- process.env.NODE_ENV = "production";
-}
-
-let cssFiles = fsSync.readdirSync(path.join(__dirname, "./css")).map((file) => {
+let cssEntryFiles = fs.readdirSync(path.join(__dirname, "./css")).map((file) => {
return path.join(__dirname, "./css", file);
});
-const bundles = [
- {
- outputFile: "frontend.js",
- entryFiles: ["./frontend/index.js"],
- babelOptions: {
+const prodCfg = {
+ transform: [
+ ["uglifyify", {
global: true,
- exclude: /node_modules\/(?!photoswipe-dynamic-caption-plugin)/,
+ exts: ".js"
+ }],
+ ["@browserify/envify", {global: true}]
+ ]
+};
+
+skulk({
+ name: "GoToSocial",
+ basePath: __dirname,
+ assetPath: "../assets/",
+ prodCfg: {
+ servers: {
+ express: false,
+ livereload: false
}
},
- {
- outputFile: "react-bundle.js",
- factors: {
- "./settings/index.js": "settings.js",
+ servers: {
+ express: {
+ proxy: "http://localhost:8081",
+ assets: "/assets"
}
},
- {
- outputFile: "_delete", // not needed, we only care for the css that's already split-out by css-extract
- entryFiles: cssFiles,
+ bundles: {
+ frontend: {
+ entryFile: "frontend",
+ outputFile: "frontend.js",
+ preset: ["js"],
+ prodCfg: prodCfg,
+ transform: [
+ ["babelify", {
+ global: true,
+ ignore: [/node_modules\/(?!(photoswipe.*))/]
+ }]
+ ],
+ },
+ settings: {
+ entryFile: "settings",
+ outputFile: "settings.js",
+ prodCfg: prodCfg,
+ presets: [
+ "react",
+ ["postcss", {
+ output: "settings-style.css"
+ }]
+ ]
+ },
+ css: {
+ entryFiles: cssEntryFiles,
+ outputFile: "_discard",
+ presets: [["postcss", {
+ output: "_split"
+ }]]
+ }
}
-];
-
-return gtsBundler(devMode, bundles); \ No newline at end of file
+}); \ No newline at end of file