diff options
author | 2022-06-09 12:51:19 +0200 | |
---|---|---|
committer | 2022-06-09 12:51:19 +0200 | |
commit | b43f9ceca9f7e02248f1d88245ede5267e8b72c8 (patch) | |
tree | 1d6b64603e74c45785bf44dde194315344843e1e /web/gotosocial-styling/index.js | |
parent | [chore] gitignore shell.nix (#639) (diff) | |
download | gotosocial-b43f9ceca9f7e02248f1d88245ede5267e8b72c8.tar.xz |
[frontend] Restructure Frontend Sources (#634)
* 🐸restructure frontend stuff, include admin and future user panel in main repo, properly deduplicate bundles for css+js across uses
* rename bundled to dist, caught by gitignore
* re-include status.css for profile template
* default to localhost
* serve frontend panels
* add todo message for abstraction
* refactor oauth registration flow
* oauth restructure
* update footer template
* change panel routes
* remove superfluous css imports
* write bundle to disk from test server, use forked budo-express
* wrap all page content in container
for robustness with addons etc injection other elements in body
* update documentation, goreleaser, Dockerfile
* update template meta tags
* add AGPL-3.0+ license header everywhere
* only attach update listener on EventEmitter
* cleaner config for various frontend bundles
* fix bundler script paths
* Merge commit 'd191931932b9293ce1be44ed08a1e69b9fcc1e25'
* fix up dockerfile, goreleaser
* go mod tidy
* add uglifyify
* move status hide/show js to frontend bundle
* fix stylesheet color( func regressions
* update contributing docs for new build path
* update goreleaser + docker building
* resolve dependency paths properly
* update package name
* use api errorhandler
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'web/gotosocial-styling/index.js')
-rw-r--r-- | web/gotosocial-styling/index.js | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/web/gotosocial-styling/index.js b/web/gotosocial-styling/index.js deleted file mode 100644 index 43384a108..000000000 --- a/web/gotosocial-styling/index.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; - -const Promise = require("bluebird"); -const fs = require("fs").promises; -const postcss = require('postcss'); -const {parse} = require("postcss-scss"); -const argv = require('minimist')(process.argv.slice(2)); - -/* - Bundle all postCSS files under the `templates/` directory separately, each prepended with the (variable) contents of ./colors.css - Outputs in plain CSS are in `build/`, split by template -*/ - -const postcssPlugins = ["postcss-strip-inline-comments", "postcss-nested", "postcss-simple-vars", "postcss-color-function"].map((plugin) => require(plugin)()); - -function getTemplates() { - return fs.readdir(`${__dirname}/templates`).then((templates) => { - return templates.map((a) => { - return [a, `${__dirname}/templates/${a}`]; - }); - }); -} - -getTemplates(); - -function bundle([template, path]) { - return Promise.try(() => { - return Promise.all([ - fs.readFile(`${__dirname}/colors.css`, "utf-8"), - fs.readFile(path, "utf-8") - ]); - }).then(([colors, style]) => { - return parse(colors + "\n" + style); - }).then((ast) => { - return postcss(postcssPlugins).process(ast, { - from: template, - to: template - }); - }).then((bundle) => { - return fs.writeFile(`${buildDir}/${template}`, bundle.css); - }).then(() => { - console.log(`Finished writing CSS to ${buildDir}/${template}`); - }); -} - -let buildDir - -// try reading from arguments first -if (argv["build-dir"] != undefined) { - buildDir = argv["build-dir"] -} - -// then try reading from environment variable -if (buildDir == undefined) { - buildDir = process.env.BUILD_DIR; -} - -// then take default -if (buildDir == undefined) { - buildDir = `${__dirname}/build`; -} - -console.log("bundling to", buildDir); - -function bundleAll() { - return getTemplates().then((templates) => { - return Promise.map(templates, bundle); - }); -} - -if (process.env.NODE_ENV != "development") { - bundleAll(); -} else { - const chokidar = require("chokidar"); - console.log("Watching for changes"); - chokidar.watch(`${__dirname}/templates`).on("all", (_, path) => { - if (path.endsWith(".css")) { - bundle([path.split("/").slice(-1)[0], path]); - } - }); - chokidar.watch(`${__dirname}/colors.css`).on("all", () => { - console.log("colors.css updated, rebuilding all templates"); - bundleAll(); - }); -}
\ No newline at end of file |