Skip to content

Commit d4e22c5

Browse files
authored
fix: await postcss for async plugins (#1036)
1 parent fc1b13d commit d4e22c5

5 files changed

Lines changed: 545 additions & 36 deletions

File tree

src/esbuild/postcss.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const postcssPlugin = ({
103103
}
104104

105105
// Transform CSS
106-
const result = postcss
106+
const result = await postcss
107107
?.default(plugins)
108108
.process(contents, { ...options, from: args.path })
109109

test/__snapshots__/index.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,8 @@ exports[`support baseUrl and paths in tsconfig.json in --dts-resolve build 1`] =
552552
export { foo };
553553
"
554554
`;
555+
556+
exports[`support tailwindcss postcss plugin 1`] = `
557+
"\\"use strict\\";
558+
"
559+
`;

test/index.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,29 @@ test('import css', async () => {
337337
expect(outFiles).toEqual(['input.css', 'input.js'])
338338
})
339339

340+
test('support tailwindcss postcss plugin', async () => {
341+
const { output, outFiles } = await run(getTestName(), {
342+
'input.ts': `
343+
import './foo.css'
344+
`,
345+
'postcss.config.js': `
346+
module.exports = {
347+
plugins: {
348+
tailwindcss: {},
349+
autoprefixer: {},
350+
}
351+
}
352+
`,
353+
'foo.css': `
354+
@tailwind base;
355+
@tailwind components;
356+
@tailwind utilities;
357+
`,
358+
})
359+
expect(output).toMatchSnapshot()
360+
expect(outFiles).toEqual(['input.css', 'input.js'])
361+
})
362+
340363
test('import css in --dts', async () => {
341364
const { output, outFiles } = await run(
342365
getTestName(),

test/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"@egoist/path-parser": "1.0.4",
55
"@types/react": "17.0.50",
66
"@types/react-dom": "17.0.17",
7+
"autoprefixer": "10.4.16",
78
"graphql": "^15.3.0",
89
"graphql-tools": "^5.0.0",
910
"react": "17.0.2",
1011
"react-dom": "17.0.2",
1112
"react-select": "5.7.0",
13+
"tailwindcss": "3.3.5",
1214
"vue": "3.2.36",
1315
"vue-router": "4.0.15"
1416
},

0 commit comments

Comments
 (0)