summaryrefslogtreecommitdiff
path: root/packages/integrations/tailwind/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/tailwind/src')
-rw-r--r--packages/integrations/tailwind/src/index.ts103
1 files changed, 0 insertions, 103 deletions
diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts
deleted file mode 100644
index 45f72ca32..000000000
--- a/packages/integrations/tailwind/src/index.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-import { fileURLToPath } from 'node:url';
-import type { AstroIntegration } from 'astro';
-import autoprefixerPlugin from 'autoprefixer';
-import tailwindPlugin from 'tailwindcss';
-import type { CSSOptions, UserConfig } from 'vite';
-
-async function getPostCssConfig(
- root: UserConfig['root'],
- postcssInlineOptions: CSSOptions['postcss'],
-) {
- let postcssConfigResult;
- // Check if postcss config is not inlined
- 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: string | undefined,
- nesting: boolean,
- root: string,
- postcssInlineOptions: CSSOptions['postcss'],
-): Promise<Partial<UserConfig>> {
- // We need to manually load postcss config files because when inlining the tailwind and autoprefixer plugins,
- // that causes vite to ignore postcss config files
- 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,
- },
- },
- };
-}
-
-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 {
- 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 }) => {
- // Inject the Tailwind postcss plugin
- updateConfig({
- vite: await getViteConfiguration(
- customConfigPath,
- nesting,
- fileURLToPath(config.root),
- config.vite.css?.postcss,
- ),
- });
-
- if (applyBaseStyles) {
- // Inject the Tailwind base import
- injectScript('page-ssr', `import '@astrojs/tailwind/base.css';`);
- }
- },
- },
- };
-}
&id=10d97b60b89540aca32efe315734391152dd059b&follow=1'>[ci] yarn formatGravatar FredKSchott 2-3/+85 2022-02-02Handles all http error code file names the same as 404 files. (#2525)Gravatar Zade Viggers 2-4/+7 2022-02-02fix(sitemap): remove debug if sitemap disabled (#2514)Gravatar Mark Pinero 1-2/+2 2022-02-02[ci] update lockfile (#2515)Gravatar Fred K. Schott 1-276/+279 2022-02-02[ci] yarn formatGravatar matthewp 1-8/+8 2022-02-02[ci] release (next) (#2523)astro@0.23.0-next.1Gravatar github-actions[bot] 28-34/+41 2022-02-02[ci] yarn formatGravatar matthewp 2-17/+29 2022-02-02Fix support for scss in static build (#2522)Gravatar Matthew Phillips 6-20/+114 2022-02-02[ci] collect statsGravatar FredKSchott 1-0/+1 2022-02-01[ci] yarn formatGravatar matthewp 2-12/+12 2022-02-01[ci] release (next) (#2492)astro@0.23.0-next.0@astrojs/test-static-build-pkg@0.0.2@astrojs/markdown-remark@0.6.1-next.0Gravatar github-actions[bot] 31-43/+93 2022-02-01[ci] collect statsGravatar FredKSchott 1-0/+1 2022-01-31update congratsbot format againGravatar Fred K. Schott 1-1/+1 2022-01-31update congratsbot againGravatar Fred K. Schott 1-1/+1 2022-01-31Remove SVG animation on GitHub/NPM (#2512)Gravatar Nate Moore 1-21/+0 2022-01-31[ci] yarn formatGravatar natemoo-re 2-4/+6 2022-01-31Add Shiki as an alternative to Prism (#2497)Gravatar Juan Martín Seery 26-9/+356 2022-01-31Deprecate unescaped HTML inside of expressions (#2489)Gravatar Nate Moore 9-31/+74