diff --git a/packages/@tailwindcss-postcss/src/fixtures/other-project/src/index.js b/packages/@tailwindcss-postcss/src/fixtures/other-project/src/index.js new file mode 100644 index 000000000000..60abb39c0a9b --- /dev/null +++ b/packages/@tailwindcss-postcss/src/fixtures/other-project/src/index.js @@ -0,0 +1 @@ +const className = "content-['other-project']" diff --git a/packages/@tailwindcss-postcss/src/index.test.ts b/packages/@tailwindcss-postcss/src/index.test.ts index 07c674da0a4c..2f633ce86d5f 100644 --- a/packages/@tailwindcss-postcss/src/index.test.ts +++ b/packages/@tailwindcss-postcss/src/index.test.ts @@ -13,7 +13,7 @@ const INPUT_CSS_PATH = `${__dirname}/fixtures/example-project/input.css` const css = String.raw beforeEach(async () => { - const { clearCache } = await import('@tailwindcss/oxide') + let { clearCache } = await import('@tailwindcss/oxide') clearCache() }) @@ -226,3 +226,59 @@ describe('plugins', () => { `) }) }) + +describe('@content', () => { + test('scans custom @content files', async () => { + let processor = postcss([ + tailwindcss({ base: `${__dirname}/fixtures/example-project`, optimize: { minify: false } }), + ]) + + let result = await processor.process( + css` + @import 'tailwindcss/utilities'; + @content '../other-project/src/**/*.js'; + `, + { from: INPUT_CSS_PATH }, + ) + + expect(result.css.trim()).toMatchInlineSnapshot(` + ".underline { + text-decoration-line: underline; + } + + .content-\\[\\'other-project\\'\\] { + --tw-content: "other-project"; + content: var(--tw-content); + } + + @supports (-moz-orient: inline) { + @layer base { + *, :before, :after, ::backdrop { + --tw-content: ""; + } + } + } + + @property --tw-content { + syntax: "*"; + inherits: false; + initial-value: ""; + }" + `) + + expect(result.messages).toContainEqual({ + type: 'dependency', + file: expect.stringMatching(/other-project\/src\/index.js$/g), + parent: expect.any(String), + plugin: '@tailwindcss/postcss', + }) + + expect(result.messages).toContainEqual({ + type: 'dir-dependency', + dir: expect.stringMatching(/other-project\/src/), + glob: '**/*.js', + parent: expect.any(String), + plugin: '@tailwindcss/postcss', + }) + }) +})