这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: await postcss for async plugins #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/esbuild/postcss.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading