-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add ability for ESBuild to watch a directory for CSS changes #10
base: main
Are you sure you want to change the base?
Conversation
Usage: plugins: [
svgrPlugin(svgrOptions),
esbuildPostCssPlugin({
cssPath:'./app/assets/stylesheets/',
plugins: [
postCssImportPlugin,
postCssTailwindNestingPlugin,
postCssTailwindPlugin('./tailwind.config.js'),
postCssAutoPrefixer
]
})
], Happy to update the readme as well. |
I think you might just watch those are bundled! |
I just wonder why this plugin uses temp files. I wrote a custom one, which is quite easy, handling file watching with no extra efforts. Just use postcss as the loader: import { Plugin } from 'esbuild'
import postcss, { AcceptedPlugin } from 'postcss'
import fs from 'fs/promises'
export const pluginPostcss = (plugins?: AcceptedPlugin[]): Plugin => {
return {
name: 'plugin-postcss',
setup(build) {
build.onLoad({ filter: /\.css$/ }, async ({ path }) => {
const processor = postcss(plugins);
const content = await fs.readFile(path);
const result = await processor.process(content, { from: path });
return {
contents: result.toString(),
loader: 'css',
}
});
},
}
}; |
This is real nice @hanayashiki i will try and if it meets my needs, would you be interested publishing this as a new esbuild plug in. Seems the maintainer doesn't need or has moved on. Understandable but the esbuild needs better plugins in its ecosystem. |
https://github.com/karolis-sh/esbuild-postcss/blob/main/src/index.ts Hi, this library is using the same way as I do. Hopefully it works for you |
Hello. I needed this make ES Build recognize changes to my stylesheets which were in a different location. The approach is copied form
esbuild-scss-plugin
and works well for me locally.I can make some changes if you desire to merge it. If not this serves as an example of how to do this.
Cheers!