Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autoprefixer on dev mode for tailwind plugin #6002

Merged
merged 5 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reverted a change in #5717 (Refactor tailwind integration setup) that…
… removed autoprefixer in non build modes
  • Loading branch information
royeden committed Jan 27, 2023
commit 28d23033bf99a8cd9b70384e73bb6016443cadda
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/src/components/Button.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---

<button
class="py-2 px-4 bg-purple-500 text-white font-semibold rounded-lg shadow-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-opacity-75"
class="appearance-none py-2 px-4 bg-purple-500 text-white font-semibold rounded-lg shadow-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-opacity-75"
>
<slot />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let { type = 'button' } = Astro.props;
---

<button
class="py-2 px-4 lg:py-3 lg:px-5 bg-purple-600 text-white font-[900] rounded-lg shadow-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-opacity-75"
class="appearance-none py-2 px-4 lg:py-3 lg:px-5 bg-purple-600 text-white font-[900] rounded-lg shadow-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:ring-opacity-75"
{type}
>
<slot />
Expand Down
11 changes: 11 additions & 0 deletions packages/astro/e2e/tailwindcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ test.describe('Tailwind CSS', () => {

const button = page.locator('button');

await expect(button, 'should have appearance none').toHaveClass(/appearance-none/);
await expect(button, 'should have appearance: none').toHaveCSS('appearance', 'none');
// await expect(button, 'should have appearance none with moz prefix').toHaveCSS(
// '-moz-appearance',
// 'none'
// );
await expect(button, 'should have appearance-none with webkit prefix').toHaveCSS(
'-webkit-appearance',
'none'
);

await expect(button, 'should have bg-purple-600').toHaveClass(/bg-purple-600/);
await expect(button, 'should have background color').toHaveCSS(
'background-color',
Expand Down
8 changes: 2 additions & 6 deletions packages/integrations/tailwind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ async function getPostCssConfig(
}

async function getViteConfiguration(
isBuild: boolean,
tailwindConfig: TailwindConfig,
viteConfig: UserConfig
) {
Expand All @@ -100,9 +99,7 @@ async function getViteConfiguration(
postcssConfigResult && postcssConfigResult.plugins ? postcssConfigResult.plugins.slice() : [];
postcssPlugins.push(tailwindPlugin(tailwindConfig));

if (isBuild) {
postcssPlugins.push(autoprefixerPlugin());
}
postcssPlugins.push(autoprefixerPlugin());
return {
css: {
postcss: {
Expand Down Expand Up @@ -140,7 +137,6 @@ export default function tailwindIntegration(options?: TailwindOptions): AstroInt
name: '@astrojs/tailwind',
hooks: {
'astro:config:setup': async ({
command,
config,
updateConfig,
injectScript,
Expand All @@ -166,7 +162,7 @@ export default function tailwindIntegration(options?: TailwindOptions): AstroInt
(userConfig?.value as TailwindConfig) ?? getDefaultTailwindConfig(config.srcDir);

updateConfig({
vite: await getViteConfiguration(command === 'build', tailwindConfig, config.vite),
vite: await getViteConfiguration(tailwindConfig, config.vite),
});

if (applyBaseStyles) {
Expand Down