Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontend] change bundler to skulk #942

Merged
merged 4 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/web/settings-panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) {
assetsPathPrefix + "/dist/settings-style.css",
},
"javascript": []string{
assetsPathPrefix + "/dist/react-bundle.js",
assetsPathPrefix + "/dist/settings.js",
},
})
Expand Down
7 changes: 7 additions & 0 deletions testrig/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"os"
"path/filepath"
"strconv"

"github.com/gin-gonic/gin"
"github.com/superseriousbusiness/gotosocial/internal/config"
Expand All @@ -44,6 +45,12 @@ func NewTestRouter(db db.DB) router.Router {
config.SetBindAddress(alternativeBindAddress)
}

if alternativePortStr := os.Getenv("GTS_PORT"); alternativePortStr != "" {
if alternativePort, err := strconv.Atoi(alternativePortStr); err == nil {
config.SetPort(alternativePort)
}
}

r, err := router.New(context.Background(), db)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion web/source/css/_colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $error-link: #185F8C; /* Error link text, can be used with $error2 (5.54) */
$fg: $white1;
$bg: $gray1;

$bg-trans: color-mod($gray5 alpha(62%));
$bg-trans: rgba(77, 78, 86, 0.62);

$bg-accent: $gray5;
$fg-accent: $blue3;
Expand Down
6 changes: 3 additions & 3 deletions web/source/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
src: url(../NotoSans-Bold.ttf) format('truetype');
}

// standard border radius for nice squircles
/* standard border radius for nice squircles */
$br: 0.4rem;
// border radius for items that are framed/bordered
// inside something with $br, eg avatar, header img
/* border radius for items that are framed/bordered
inside something with $br, eg avatar, header img */
$br-inner: 0.2rem;

html, body {
Expand Down
109 changes: 57 additions & 52 deletions web/source/index.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,69 @@
/*
GoToSocial
Copyright (C) 2021-2022 GoToSocial Authors [email protected]

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

f0x52 marked this conversation as resolved.
Show resolved Hide resolved
"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 skulk = require("skulk");
const fs = require("fs");
const path = require("path");

const gtsBundler = require("./lib/bundler");

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);
});
200 changes: 0 additions & 200 deletions web/source/lib/bundler.js

This file was deleted.

Loading