Skip to content

Commit

Permalink
Testing Bun Migration
Browse files Browse the repository at this point in the history
Bun is just *really fast* and I enjoy using it. I have no issues running it on my local machine but I need to see if it will work just as well when deployed on github
  • Loading branch information
Woedenaz committed Dec 20, 2023
1 parent e794782 commit 88edaf4
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 66 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults and not op_mini all or iOS <= 14
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Treat certain files as binary
*.min.css binary linguist-generated
pnpm-lock.yaml binary linguist-generated
bun.lockb binary linguist-generated
/scp-test-page binary linguist-generated
27 changes: 2 additions & 25 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 19

- name: Setup PNPM
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Bun
uses: oven-sh/setup-bun@v1

- name: Build
run: make
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist/
# NPM
node_modules/
package-lock.json
pnpm-lock.yaml
bun.lockb

# Misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dist/

# NPM
node_modules/
pnpm-lock.yaml
bun.lockb

# Misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ normalize.css

# NPM
node_modules/
pnpm-lock.yaml
bun.lockb

# Misc
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ A base theme for the SCP Wiki utilizing more current CSS styling standards.
On a UNIX-like environment with GNU Makefile, you can build Black Highlighter from its source files using the following:

```
pnpm install
bun i
make
```

This will perform the combinations, minifications, etc. all automatically. All affected files will appear in `/dist`.

The `Makefile` was constructed to be rigorous with requisites and outputs, it should only rebuild what has since been modified. As such, you can run the build in parallel with jobservers, such as `make -j 4`.

However (for obvious reasons) `make` cannot determine if `node_modules` has all the required dependencies, it merely checks if the `node_modules/` directory exists. You will need to re-run `npm install` if you modify npm's local state.
However (for obvious reasons) `make` cannot determine if `node_modules` has all the required dependencies, it merely checks if the `node_modules/` directory exists. You will need to re-run `bun install` if you modify npm's local state.

Additionally, you can run `make -B` to force re-building all targets, or `make clean` to dispose of the `/dist` directory.
8 changes: 4 additions & 4 deletions build/css.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ dist/css/parts/%: src/css/parts/%
# CSS rules
dist/css/min/black-highlighter.min.css: src/css/black-highlighter.css $(BUILD_SOURCES) $(CSS_SOURCES) node_modules
build/install.sh 644 $< dist/css/black-highlighter-imports.css
pnpm postcss dist/css/black-highlighter-imports.css --config build --env development -o dist/css/black-highlighter.css
pnpm postcss dist/css/black-highlighter-imports.css --config build --env production -o $@
bun postcss dist/css/black-highlighter-imports.css --config build --env development -o dist/css/black-highlighter.css
bun postcss dist/css/black-highlighter-imports.css --config build --env production -o $@

dist/css/min/normalize.min.css: src/css/normalize.css $(BUILD_SOURCES) node_modules
build/install.sh 644 $< dist/css/normalize.css
pnpm postcss dist/css/normalize.css --config build --env development -r
pnpm postcss dist/css/normalize.css --config build --env production -o $@
bun postcss dist/css/normalize.css --config build --env development -r
bun postcss dist/css/normalize.css --config build --env production -o $@
4 changes: 2 additions & 2 deletions build/images.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dist/img/social-icons/%: src/img/social-icons/%

# Images to optimize
dist/img/%.png: src/img/%.png node_modules
pnpm svgo $< -o $@
bun svgo $< -o $@

dist/img/%.svg: src/img/%.svg node_modules
pnpm svgo $< -o $@
bun svgo $< -o $@
6 changes: 3 additions & 3 deletions build/meta.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DIRECTORIES := \
$(DIRECTORIES):
mkdir -p $@

# pnpm rules
node_modules: package.json pnpm-lock.yaml
pnpm install
# bun rules
node_modules: package.json bun.lockb
bun install
touch node_modules
36 changes: 17 additions & 19 deletions build/postcss.config.js → build/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
"use strict";

module.exports = (ctx) => {

const path = require("path");
const globalData = require("@csstools/postcss-global-data");
const stylelint = require("stylelint");
const postcssImport = require("postcss-import");
const postcssMixins = require("postcss-mixins");
const presetEnv = require("postcss-preset-env");
const autoprefixer = require("autoprefixer");
const url = require("postcss-url");
const csso = require("postcss-csso");
const reporter = require("postcss-reporter");
const browserslist = require("../package.json").browserslist;

/* Disabling LightningCSS until its functionality is a little more robust
const lightningcss = require("postcss-lightningcss");
*/
import fs from "fs";
import path from "path";
import globalData from "@csstools/postcss-global-data";
import stylelint from "stylelint";
import postcssImport from "postcss-import";
import postcssMixins from "postcss-mixins";
import presetEnv from "postcss-preset-env";
import autoprefixer from "autoprefixer";
import url from "postcss-url";
import csso from "postcss-csso";
import reporter from "postcss-reporter";
/* Disabling LightningCSS until its functionality is a little more robust
import lightningCSS from "postcss-lightningcss";
*/

export default (ctx) => {

const nodeEnv = ctx.env;
const dev = nodeEnv === "development";
const browserslist = fs.readFileSync(path.resolve(ctx.file.dirname, "../../.browserslistrc"), "utf8").trim();

const globalDataOptions = {
files: [ path.join( ctx.file.dirname,"/parts/root.css" ) ]
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"url": "https://github.com/Nu-SCPTheme/Black-Highlighter"
},
"engines": {
"node": ">=19",
"pnpm": ">=7"
"bun": ">=1.0.17"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.0.0",
Expand All @@ -19,7 +18,6 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"lightningcss": "^1.19.0",
"node": "^21.0.0",
"postcss": "^8.4.21",
"postcss-cli": "^11.0.0",
"postcss-csso": "^6.0.1",
Expand All @@ -37,8 +35,7 @@
},
"scripts": {
"build": "make",
"base": "postcss $npm_config_bhl_i --config build/postcss.config.js -o $npm_config_bhl_o -w --env $npm_config_bhl_env --verbose",
"watch": "pnpm --bhl-i=src/css/black-highlighter.css --bhl-o=dist/css/black-highlighter.css --bhl-env=development base & pnpm --bhl-i=src/css/black-highlighter.css --bhl-o=dist/css/min/black-highlighter.min.css --bhl-env=production base & pnpm --bhl-i=src/css/normalize.css --bhl-o=dist/css/min/normalize.min.css --bhl-env=development base"
},
"browserslist": "defaults and not op_mini all or iOS <= 14"
"base": "postcss $npm_config_bhl_i --config build/postcss.config.mjs -o $npm_config_bhl_o -w --env $npm_config_bhl_env --verbose",
"watch": "bun --bhl-i=src/css/black-highlighter.css --bhl-o=dist/css/black-highlighter.css --bhl-env=development base & bun --bhl-i=src/css/black-highlighter.css --bhl-o=dist/css/min/black-highlighter.min.css --bhl-env=production base & bun --bhl-i=src/css/normalize.css --bhl-o=dist/css/min/normalize.min.css --bhl-env=development base"
}
}

0 comments on commit 88edaf4

Please sign in to comment.