Skip to content

Commit

Permalink
fix: await postcss for async plugins (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed Nov 18, 2023
1 parent fc1b13d commit d4e22c5
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/esbuild/postcss.ts
Expand Up @@ -103,7 +103,7 @@ export const postcssPlugin = ({
}

// Transform CSS
const result = postcss
const result = await postcss
?.default(plugins)
.process(contents, { ...options, from: args.path })

Expand Down
5 changes: 5 additions & 0 deletions test/__snapshots__/index.test.ts.snap
Expand Up @@ -552,3 +552,8 @@ exports[`support baseUrl and paths in tsconfig.json in --dts-resolve build 1`] =
export { foo };
"
`;
exports[`support tailwindcss postcss plugin 1`] = `
"\\"use strict\\";
"
`;
23 changes: 23 additions & 0 deletions test/index.test.ts
Expand Up @@ -337,6 +337,29 @@ test('import css', async () => {
expect(outFiles).toEqual(['input.css', 'input.js'])
})

test('support tailwindcss postcss plugin', async () => {
const { output, outFiles } = await run(getTestName(), {
'input.ts': `
import './foo.css'
`,
'postcss.config.js': `
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}
`,
'foo.css': `
@tailwind base;
@tailwind components;
@tailwind utilities;
`,
})
expect(output).toMatchSnapshot()
expect(outFiles).toEqual(['input.css', 'input.js'])
})

test('import css in --dts', async () => {
const { output, outFiles } = await run(
getTestName(),
Expand Down
2 changes: 2 additions & 0 deletions test/package.json
Expand Up @@ -4,11 +4,13 @@
"@egoist/path-parser": "1.0.4",
"@types/react": "17.0.50",
"@types/react-dom": "17.0.17",
"autoprefixer": "10.4.16",
"graphql": "^15.3.0",
"graphql-tools": "^5.0.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-select": "5.7.0",
"tailwindcss": "3.3.5",
"vue": "3.2.36",
"vue-router": "4.0.15"
},
Expand Down

0 comments on commit d4e22c5

Please sign in to comment.