Skip to content
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
Prev Previous commit
Next Next commit
Fix line breaks by keeping everything a string until it's necessary t…
…o convert
  • Loading branch information
philipp-spiess committed Oct 11, 2024
commit 5e26bc890b95fdd3a2e7af6650ddac611cdcf266
1 change: 0 additions & 1 deletion integrations/upgrade/js-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ test(
@import 'tailwindcss';

@source './**/*.{html,js}';

@source '../my-app/**/*.{html,js}';

@variant dark (&:where(.dark, .dark *));
Expand Down
16 changes: 6 additions & 10 deletions packages/@tailwindcss-upgrade/src/codemods/migrate-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path'
import { AtRule, type Plugin, Root } from 'postcss'
import postcss, { AtRule, type Plugin, Root } from 'postcss'
import { normalizePath } from '../../../@tailwindcss-node/src/normalize-path'
import type { JSConfigMigration } from '../migrate-js-config'
import type { Stylesheet } from '../stylesheet'
Expand Down Expand Up @@ -39,21 +39,17 @@ export function migrateConfig(
}),
)
} else {
let css = '\n\n'
for (let source of jsConfigMigration.sources) {
let absolute = path.resolve(source.base, source.pattern)
cssConfig.append(
new AtRule({
name: 'source',
params: `'${relativeToStylesheet(sheet, absolute)}'`,
}),
)
css += `@source '${relativeToStylesheet(sheet, absolute)}';\n`
}

if (jsConfigMigration.css.nodes.length > 0 && jsConfigMigration.sources.length > 0) {
jsConfigMigration.css.nodes[0].raws.before = '\n\n'
if (jsConfigMigration.sources.length > 0) {
css = css + '\n'
}

cssConfig.append(jsConfigMigration.css.nodes)
cssConfig.append(postcss.parse(css + jsConfigMigration.css))
}

// Inject the `@config` in a sensible place
Expand Down
8 changes: 2 additions & 6 deletions packages/@tailwindcss-upgrade/src/migrate-js-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'node:fs/promises'
import { dirname } from 'path'
import postcss from 'postcss'
import type { Config } from 'tailwindcss'
import { fileURLToPath } from 'url'
import { loadModule } from '../../@tailwindcss-node/src/compile'
Expand All @@ -20,7 +19,7 @@ export type JSConfigMigration =
// Could not convert the config file, need to inject it as-is in a @config directive
null | {
sources: { base: string; pattern: string }[]
css: postcss.Root
css: string
}

export async function migrateJsConfig(
Expand Down Expand Up @@ -56,7 +55,7 @@ export async function migrateJsConfig(

return {
sources,
css: postcss.parse(cssConfigs.join('\n')),
css: cssConfigs.join('\n'),
}
}

Expand All @@ -73,10 +72,7 @@ async function migrateTheme(unresolvedConfig: Config & { theme: any }): Promise<

if (!resetNamespaces.has(key[0])) {
resetNamespaces.set(key[0], false)
// css += ` --${keyPathToCssProperty([key[0]])}-*: initial;\n`
}

// css += ` --${keyPathToCssProperty(key)}: ${value};\n`
}

let themeValues = deepMerge({}, [overwriteTheme, extendTheme], mergeThemeExtension)
Expand Down