chore(devex): tailwind v4 (via CLI) + upgrade guide for tailwind v4 (#29562)

Co-authored-by: Marius Andra <marius.andra@gmail.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lucas Ricoy <2034367+lricoy@users.noreply.github.com>
Co-authored-by: Robbie <robbie.coomber@gmail.com>
Co-authored-by: Dylan Martin <dylan@posthog.com>
Co-authored-by: Haven <haven@posthog.com>
Co-authored-by: Paul D'Ambra <paul@posthog.com>
Co-authored-by: Paweł Szczur <orian@users.noreply.github.com>
Co-authored-by: Ben White <ben@posthog.com>
This commit is contained in:
Adam Leith
2025-03-06 11:41:33 +00:00
committed by GitHub
parent b689703110
commit 31fa949aa6
325 changed files with 318 additions and 106 deletions

View File

@@ -7,6 +7,7 @@
!common/eslint_rules
!common/plugin_transpiler/*.*
!common/plugin_transpiler/src
!common/tailwind
!dags
!ee
!frontend/@posthog

1
.gitignore vendored
View File

@@ -46,6 +46,7 @@ celerybeat.pid
common/hogvm/typescript/.parcel-cache
common/hogvm/typescript/dist
common/plugin_transpiler/dist
common/tailwind/dist
coverage-*.xml
cypress/**/*.diff.png
cypress/downloads/

View File

@@ -1 +0,0 @@
frontend/dist/

View File

@@ -26,13 +26,14 @@ WORKDIR /code
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
COPY turbo.json package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./
COPY frontend/package.json frontend/tailwind.config.js frontend/
COPY frontend/package.json frontend/
COPY frontend/bin/ frontend/bin/
COPY bin/ bin/
COPY patches/ patches/
COPY common/hogvm/typescript/ common/hogvm/typescript/
COPY common/esbuilder/ common/esbuilder/
COPY common/eslint_rules/ common/eslint_rules/
COPY common/tailwind/ common/tailwind/
COPY products/ products/
COPY ee/frontend/ ee/frontend/
RUN --mount=type=cache,id=pnpm,target=/tmp/pnpm-store \

View File

@@ -14,7 +14,6 @@ import fse from 'fs-extra'
import * as path from 'path'
import postcss from 'postcss'
import postcssPresetEnv from 'postcss-preset-env'
import tailwindcss from 'tailwindcss'
import ts from 'typescript'
const defaultHost = process.argv.includes('--host') && process.argv.includes('0.0.0.0') ? '0.0.0.0' : 'localhost'
@@ -85,7 +84,7 @@ export function copyIndexHtml(
window.ESBUILD_LOAD_CHUNKS('index');
`
// Snippet to dynamically load the css based on window.JS_URL
// Modified CSS loader to handle both files
const cssLoader = `
const link = document.createElement("link");
link.rel = "stylesheet";
@@ -140,8 +139,7 @@ export const commonConfig = {
plugins: [
sassPlugin({
async transform(source, resolveDir, filePath) {
// Sync the plugins list with postcss.config.js
const plugins = [tailwindcss, autoprefixer, postcssPresetEnv({ stage: 0 })]
const plugins = [autoprefixer, postcssPresetEnv({ stage: 0 })]
if (!isDev) {
plugins.push(cssnano({ preset: 'default' }))
}
@@ -362,8 +360,6 @@ export async function buildOrWatch(config) {
}
if (isDev) {
const tailwindConfigJsPath = path.resolve(absWorkingDir, '../tailwind.config.js')
chokidar
.watch(
[
@@ -372,7 +368,6 @@ export async function buildOrWatch(config) {
path.resolve(absWorkingDir, '../common'),
path.resolve(absWorkingDir, '../products/*/manifest.json'),
path.resolve(absWorkingDir, '../products/*/frontend/**/*'),
tailwindConfigJsPath,
],
{
ignored: /.*(Type|\.test\.stories)\.[tj]sx?$/,
@@ -389,11 +384,11 @@ export async function buildOrWatch(config) {
gatherProductManifests()
}
if (inputFiles.has(filePath) || filePath === tailwindConfigJsPath) {
if (filePath.match(/\.tsx?$/) || filePath === tailwindConfigJsPath) {
if (inputFiles.has(filePath)) {
if (filePath.match(/\.tsx?$/)) {
// For changed TS/TSX files, we need to initiate a Tailwind JIT rescan
// in case any new utility classes are used. `touch`ing `base.scss` (or the file that imports tailwind.css) achieves this.
await touchFile(path.resolve(absWorkingDir, 'src/styles/base.scss'))
await touchFile(path.resolve(absWorkingDir, '../common/tailwind/tailwind.css'))
}
void debouncedBuild()
}

View File

@@ -1,5 +1,7 @@
const config = require('../../frontend/tailwind.config.js') // eslint-disable-line no-undef
module.exports = { // eslint-disable-line no-undef
// eslint-disable-next-line no-undef
const config = require('../../frontend/tailwind.config.js')
// eslint-disable-next-line no-undef
module.exports = {
...config,
content: config.content.map((path) => path.replace('../', '../../'))
}

View File

@@ -7,6 +7,9 @@
},
"prepare": {
"dependsOn": ["@posthog/frontend#prepare"]
},
"start": {
"dependsOn": ["@posthog/frontend#prepare"]
}
}
}

View File

@@ -0,0 +1,15 @@
{
"name": "@posthog/tailwind",
"scripts": {
"build": "pnpm dlx @tailwindcss/cli -i ./tailwind.css -o ./dist/tailwind.css",
"start": "pnpm dlx @tailwindcss/cli -i ./tailwind.css -o ./dist/tailwind.css --watch"
},
"dependencies": {
"tailwindcss": "4.0.7",
"@tailwindcss/container-queries": "^0.1.1"
},
"devDependencies": {
"@tailwindcss/cli": "^4.0.7"
},
"peerDependencies": {}
}

View File

@@ -308,15 +308,14 @@ const deprecatedColors = {
const config = {
content: [
// Starting all paths with '.." to share this between frontend/, cypress/, playwright/ and common/storybook/
// Update common/storybook/tailwind.config.js if you change this
'../frontend/src/**/*.{ts,tsx}',
'../ee/frontend/**/*.{ts,tsx}',
'../frontend/src/index.html',
'../products/**/frontend/**/*.{ts,tsx}',
'../common/**/src/**/*.{ts,tsx}',
'../common/**/frontend/**/*.{ts,tsx}',
'!../frontend/src/**/*Type.ts',
// Starting all paths with '../.." to share this between frontend/, cypress/, playwright/ and common/storybook/
'../../frontend/src/**/*.{ts,tsx}',
'../../ee/frontend/**/*.{ts,tsx}',
'../../frontend/src/index.html',
'../../products/**/frontend/**/*.{ts,tsx}',
'../../common/**/src/**/*.{ts,tsx}',
'../../common/**/frontend/**/*.{ts,tsx}',
'!../../frontend/src/**/*Type.ts',
],
darkMode: ['selector', '[theme="dark"]'],
important: true,
@@ -788,14 +787,12 @@ const config = {
// Standard spacing utilities for backwards compatibility
for (const [key, value] of Object.entries(spacing)) {
const safeKey = key.toString().replace('.', '_');
newUtilities[`.deprecated-space-y-${safeKey} > :not([hidden]) ~ :not([hidden])`] = {
newUtilities[`.deprecated-space-y-${key} > :not([hidden]) ~ :not([hidden])`] = {
'--tw-space-y-reverse': '0',
'margin-top': `calc(${value} * calc(1 - var(--tw-space-y-reverse)))`,
'margin-bottom': `calc(${value} * var(--tw-space-y-reverse))`,
};
newUtilities[`.deprecated-space-x-${safeKey} > :not([hidden]) ~ :not([hidden])`] = {
newUtilities[`.deprecated-space-x-${key} > :not([hidden]) ~ :not([hidden])`] = {
'--tw-space-x-reverse': '0',
'margin-right': `calc(${value} * var(--tw-space-x-reverse))`,
'margin-left': `calc(${value} * calc(1 - var(--tw-space-x-reverse)))`,

View File

@@ -0,0 +1,4 @@
@import 'tailwindcss';
/* if this shows a warning, cahnge the type of file in vscode to 'tailwind CSS' */
@config "./tailwind.config.js";

View File

@@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"build": {
"cache": false
}
}
}

View File

@@ -1,2 +1,4 @@
const baseConfig = require('../frontend/tailwind.config.js') // eslint-disable-line no-undef
module.exports = baseConfig // eslint-disable-line no-undef
// eslint-disable-next-line no-undef
const baseConfig = require('../frontend/tailwind.config.js')
// eslint-disable-next-line no-undef
module.exports = baseConfig

View File

@@ -0,0 +1,2 @@
../frontend/dist/
../common/tailwind/dist/

View File

@@ -43,7 +43,7 @@ module.exports = {
'scss/at-rule-no-unknown': [
true,
{
ignoreAtRules: ['tailwind'],
ignoreAtRules: ['tailwind', 'config'],
},
],
'scss/operator-no-newline-after': null, // Doesn't always play well with prettier

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 KiB

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 KiB

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 KiB

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Some files were not shown because too many files have changed in this diff Show More