Skip to content

Commit

Permalink
Merge pull request #233 from Nu-SCPTheme/bun-migration
Browse files Browse the repository at this point in the history
Bun migration
  • Loading branch information
Woedenaz authored Dec 20, 2023
2 parents e794782 + aeda660 commit 195b83c
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 101 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dist/
# NPM
node_modules/
package-lock.json
pnpm-lock.yaml

# 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 i` if you modify node.js'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
37 changes: 18 additions & 19 deletions build/postcss.config.js → build/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
"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 browserslistpath = path.resolve(ctx.file.dirname, "../../.browserslistrc");
const browserslist = fs.readFileSync(browserslistpath, "utf8").trim();

const globalDataOptions = {
files: [ path.join( ctx.file.dirname,"/parts/root.css" ) ]
Expand Down
Binary file added bun.lockb
Binary file not shown.
82 changes: 40 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
{
"name": "black-highlighter",
"description": "Modern base theme for the SCP Wiki (build process)",
"version": "1.0.0",
"authors": "Woedenaz, Croquembouche",
"license": "CC-BY-SA-3.0",
"repository": {
"type": "git",
"url": "https://github.com/Nu-SCPTheme/Black-Highlighter"
},
"engines": {
"node": ">=19",
"pnpm": ">=7"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.0.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.34.0",
"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",
"postcss-import": "^15.1.0",
"postcss-lightningcss": "^1.0.0",
"postcss-mixins": "^9.0.4",
"postcss-preset-env": "^9.0.0",
"postcss-reporter": "^7.0.5",
"postcss-url": "^10.1.3",
"prettier": "^3.0.0",
"stylelint": "^16.0.2",
"stylelint-config-property-sort-order-smacss": "^10.0.0",
"stylelint-config-standard": "^35.0.0",
"svgo": "^3.0.2"
},
"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"
"name": "black-highlighter",
"description": "Modern base theme for the SCP Wiki (build process)",
"version": "1.0.0",
"authors": "Woedenaz, Croquembouche",
"license": "CC-BY-SA-3.0",
"repository": {
"type": "git",
"url": "https://github.com/Nu-SCPTheme/Black-Highlighter"
},
"engines": {
"bun": ">=1.0.17"
},
"devDependencies": {
"@csstools/postcss-global-data": "^2.0.0",
"autoprefixer": "^10.4.13",
"cross-env": "^7.0.3",
"eslint": "^8.34.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"lightningcss": "^1.19.0",
"postcss": "^8.4.21",
"postcss-cli": "^11.0.0",
"postcss-csso": "^6.0.1",
"postcss-import": "^15.1.0",
"postcss-lightningcss": "^1.0.0",
"postcss-mixins": "^9.0.4",
"postcss-preset-env": "^9.0.0",
"postcss-reporter": "^7.0.5",
"postcss-url": "^10.1.3",
"prettier": "^3.0.0",
"stylelint": "^16.0.2",
"stylelint-config-property-sort-order-smacss": "^10.0.0",
"stylelint-config-standard": "^35.0.0",
"svgo": "^3.0.2"
},
"scripts": {
"build": "make",
"base": "cross-env postcss $bhl_i --config build/postcss.config.mjs -o $bhl_o -w --env $bhl_env --verbose",
"watch": "cross-env bhl_i=src/css/black-highlighter.css bhl_o=dist/css/black-highlighter.css bhl_env=development bun base & cross-env bhl_i=src/css/black-highlighter.css bhl_o=dist/css/min/black-highlighter.min.css bhl_env=production bun base & cross-env bhl_i=src/css/normalize.css bhl_o=dist/css/min/normalize.min.css bhl_env=development bun base"
}
}

0 comments on commit 195b83c

Please sign in to comment.