Skip to content

Commit

Permalink
fix: use resolveConfig to preserve defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Mar 21, 2022
1 parent a83e355 commit 19f29cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/integrations/tailwind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import { fileURLToPath } from 'url';
import path from 'path';
import tailwindPlugin from 'tailwindcss';
import type { TailwindConfig } from 'tailwindcss/tailwind-config';
import resolveConfig from 'tailwindcss/resolveConfig.js';
import autoprefixerPlugin from 'autoprefixer';
import load from '@proload/core';

function getDefaultTailwindConfig(srcUrl: URL): TailwindConfig {
return {
return resolveConfig({
theme: {
extend: {},
},
plugins: [],
content: [path.join(fileURLToPath(srcUrl), `**`, `*.{astro,html,js,jsx,svelte,ts,tsx,vue}`)],
};
});
}

async function getUserConfig(projectRoot: URL, configPath?: string) {
Expand Down Expand Up @@ -64,7 +65,7 @@ export default function tailwindIntegration(options: TailwindOptions): AstroInte
if (applyAstroConfigPreset && userConfig?.value) {
// apply Astro config as a preset to user config
// this avoids merging or applying nested spread operators ourselves
tailwindConfig.presets = [...(tailwindConfig.presets || []), getDefaultTailwindConfig(config.src)];
tailwindConfig.presets = [getDefaultTailwindConfig(config.src), ...(tailwindConfig.presets || [])];
}

config.styleOptions.postcss.plugins.push(tailwindPlugin(tailwindConfig));
Expand Down

0 comments on commit 19f29cb

Please sign in to comment.