Skip to content

Commit

Permalink
fix(css): Make nib not include box flex fallback
Browse files Browse the repository at this point in the history
Kind of annoying figuring out the correct AST node type for defining this at the compiler

Fixes #248
  • Loading branch information
klarstrup committed Sep 16, 2024
1 parent 6628907 commit 22de755
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
14 changes: 9 additions & 5 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {readFileSync} from 'fs';
import {writeFile} from 'fs/promises';
import nib from 'nib';
import path from 'path';
import stylus from 'stylus';
import ts from 'typescript';
import * as url from 'url';
import packageJson from './package.json' assert {type: 'json'};
Expand Down Expand Up @@ -73,8 +74,11 @@ const commonOptions = {
loader: {'.styl': 'empty'},
metafile: true
};
const stylus = stylusLoader({
stylusOptions: {import: [nib.path + '/nib/index.styl']}
const stylusPlugin = stylusLoader({
stylusOptions: {
import: [nib.path + '/nib/index.styl'],
define: [['flex-version', [new stylus.nodes.Ident('flex')]]]
}
});

switch (process.argv[2]) {
Expand All @@ -86,7 +90,7 @@ switch (process.argv[2]) {
outfile: path.join(distDir, output + '.js'),
platform: 'browser',
globalName: name && `self[${JSON.stringify(name)}]`,
plugins: [stylus],
plugins: [stylusPlugin],
metafile: true,
banner: {
js: "new EventSource('/esbuild').addEventListener('change', () => location.reload());"
Expand Down Expand Up @@ -121,7 +125,7 @@ switch (process.argv[2]) {
outfile: path.join(distDir, output + '.js'),
platform: 'browser',
globalName: `self[${JSON.stringify(name)}]`,
plugins: [stylus]
plugins: [stylusPlugin]
}),
name &&
build({
Expand All @@ -131,7 +135,7 @@ switch (process.argv[2]) {
outfile: path.join(distDir, output + '.min.js'),
platform: 'browser',
globalName: `self[${JSON.stringify(name)}]`,
plugins: [stylus]
plugins: [stylusPlugin]
}),
build({
...commonOptions,
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"@playwright/browser-chromium": "^1.38.1",
"@types/jest": "^29.5.5",
"@types/mustache": "^4.2.3",
"@types/nib": "^1.1.2",
"@types/node": "^18.16.12",
"@types/stylus": "^0.48.43",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"app-root-path": "^3.1.0",
Expand Down

0 comments on commit 22de755

Please sign in to comment.