Skip to content

Commit

Permalink
Transpile CSS Nesting with postcss-nesting & Modularize
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster committed Jun 5, 2024
1 parent 5765ee9 commit 7c1b392
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 21 deletions.
6 changes: 0 additions & 6 deletions .postcssrc.json

This file was deleted.

109 changes: 103 additions & 6 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 @@ -2,6 +2,7 @@
"name": "hkilang-tts",
"version": "0.0.0",
"description": "香港本土語言文字轉語音朗讀器",
"type": "module",
"scripts": {
"start": "parcel public/index.html --dist-dir build --open --port 3000",
"build": "parcel build public/index.html --dist-dir build --public-url /TTS --no-cache"
Expand All @@ -28,6 +29,7 @@
"eslint-plugin-react-refresh": "^0.4.7",
"parcel": "^2.12.0",
"parcel-transformer-papaparse": "^0.1.0",
"postcss-nesting": "^12.1.5",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
},
Expand Down
13 changes: 13 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-check
import postCSSNesting from "postcss-nesting";
import tailwindcss from "tailwindcss";
import tailwindcssNesting from "tailwindcss/nesting/index.js"; // eslint-disable-line import/extensions

/** @satisfies { import("postcss").ProcessOptions & { plugins?: import("postcss").AcceptedPlugin[] } } */
const exports = {
plugins: [
tailwindcssNesting(postCSSNesting({ edition: "2024-02" })),
tailwindcss(),
],
};
export default exports;
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
&:first-child,
hr + &,
& + hr {
/* must be transformed by transpiler conforming the web standard (postcss-nesting, not postcss-nested) for this to work */
@apply mt-[1.125rem];
}
}
Expand Down
22 changes: 16 additions & 6 deletions tailwind.config.js → tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/** @type {import("tailwindcss").Config} */
module.exports = {
import daisyui from "daisyui";

import type { Config as DaisyUIConfig } from "daisyui";
import type { Config } from "tailwindcss";

export default {
important: true,
content: ["./src/**/*"],
content: ["./public/index.html", "./src/**/*"],
theme: {
fontFamily: {
sans: [
Expand All @@ -24,9 +28,15 @@ module.exports = {
"Segoe UI Symbol",
"Noto Color Emoji",
],
symbol: [
"-apple-system",
"BlinkMacSystemFont",
"Segoe UI Symbol",
"sans-serif",
],
},
},
plugins: [require("daisyui")],
plugins: [daisyui],
daisyui: {
themes: [
{
Expand All @@ -50,5 +60,5 @@ module.exports = {
},
},
],
},
};
} satisfies DaisyUIConfig,
} satisfies Config;
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"compilerOptions": {
"target": "ES6",
"target": "ES2017",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"moduleDetection": "force",

"strict": true,
"allowUnusedLabels": false,
Expand All @@ -26,5 +27,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
"include": ["src", "*.config.[jt]s"]
}

0 comments on commit 7c1b392

Please sign in to comment.