🎨 Fix CSS: Import global.css + plain CSS styles

CSS was not being imported! Fixed:

 Added 'import ../styles/global.css' to BaseLayout.astro
 Rewrote CSS with plain CSS (not @apply which wasn't working)
 Cookie banner has inline styles as backup
 Font size: 16px base
 Solid colors: green-600 (#16a34a), gray-900 (#111827)
 Footer has policy links

Build: 12 pages 
This commit is contained in:
Kunthawat Greethong
2026-03-10 08:21:30 +07:00
parent 0d3c8fa5b8
commit 3ed9f3f3ff
11122 changed files with 1624110 additions and 180 deletions

View File

@@ -0,0 +1,23 @@
import type { AstroIntegration } from 'astro';
type TailwindOptions = {
/**
* Path to your tailwind config file
* @default 'tailwind.config.mjs'
*/
configFile?: string;
/**
* Apply Tailwind's base styles
* Disabling this is useful when further customization of Tailwind styles
* and directives is required. See {@link https://tailwindcss.com/docs/functions-and-directives#tailwind Tailwind's docs}
* for more details on directives and customization.
* @default true
*/
applyBaseStyles?: boolean;
/**
* Add CSS nesting support using `tailwindcss/nesting`. See {@link https://tailwindcss.com/docs/using-with-preprocessors#nesting Tailwind's docs}
* for how this works with `postcss-nesting` and `postcss-nested`.
*/
nesting?: boolean;
};
export default function tailwindIntegration(options?: TailwindOptions): AstroIntegration;
export {};

View File

@@ -0,0 +1,61 @@
import { fileURLToPath } from "node:url";
import autoprefixerPlugin from "autoprefixer";
import tailwindPlugin from "tailwindcss";
async function getPostCssConfig(root, postcssInlineOptions) {
let postcssConfigResult;
if (!(typeof postcssInlineOptions === "object" && postcssInlineOptions !== null)) {
let { default: postcssrc } = await import("postcss-load-config");
const searchPath = typeof postcssInlineOptions === "string" ? postcssInlineOptions : root;
try {
postcssConfigResult = await postcssrc({}, searchPath);
} catch {
postcssConfigResult = null;
}
}
return postcssConfigResult;
}
async function getViteConfiguration(tailwindConfigPath, nesting, root, postcssInlineOptions) {
const postcssConfigResult = await getPostCssConfig(root, postcssInlineOptions);
const postcssOptions = postcssConfigResult?.options ?? {};
const postcssPlugins = postcssConfigResult?.plugins?.slice() ?? [];
if (nesting) {
const tailwindcssNestingPlugin = (await import("tailwindcss/nesting/index.js")).default;
postcssPlugins.push(tailwindcssNestingPlugin());
}
postcssPlugins.push(tailwindPlugin(tailwindConfigPath));
postcssPlugins.push(autoprefixerPlugin());
return {
css: {
postcss: {
...postcssOptions,
plugins: postcssPlugins
}
}
};
}
function tailwindIntegration(options) {
const applyBaseStyles = options?.applyBaseStyles ?? true;
const customConfigPath = options?.configFile;
const nesting = options?.nesting ?? false;
return {
name: "@astrojs/tailwind",
hooks: {
"astro:config:setup": async ({ config, updateConfig, injectScript }) => {
updateConfig({
vite: await getViteConfiguration(
customConfigPath,
nesting,
fileURLToPath(config.root),
config.vite.css?.postcss
)
});
if (applyBaseStyles) {
injectScript("page-ssr", `import '@astrojs/tailwind/base.css';`);
}
}
}
};
}
export {
tailwindIntegration as default
};