diff --git a/esbuild.mjs b/esbuild.mjs index 10323f09..229feddf 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -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'}; @@ -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]) { @@ -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());" @@ -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({ @@ -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, diff --git a/package-lock.json b/package-lock.json index 869d50c3..c27119ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,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", @@ -3873,6 +3875,12 @@ "integrity": "sha512-MG+oI3oelPKLN2gpkel08v6Tp6zU2zZQRq+eSpRsFtLNTd2kxZolOHQTmQQs0wqXTLOqs+ri3tRUaagH5u0quw==", "dev": true }, + "node_modules/@types/nib": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/nib/-/nib-1.1.2.tgz", + "integrity": "sha512-czgRptAQeGoY8Td2l4joiTbKgH6W27vO4kAG3sdebcnhUtkEDjAtVR4/uz2ilLWeTVWioVRmhlT98c2oo4RUHA==", + "dev": true + }, "node_modules/@types/node": { "version": "18.16.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.12.tgz", @@ -3891,6 +3899,15 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, + "node_modules/@types/stylus": { + "version": "0.48.43", + "resolved": "https://registry.npmjs.org/@types/stylus/-/stylus-0.48.43.tgz", + "integrity": "sha512-72dv/zdhuyXWVHUXG2VTPEQdOG+oen95/DNFx2aMFFaY6LoITI6PwEqf5x31JF49kp2w9hvUzkNfTGBIeg61LQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/tough-cookie": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz", diff --git a/package.json b/package.json index c4429590..729f5c0f 100644 --- a/package.json +++ b/package.json @@ -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",