Private plugin with ES Module: any example? #1969
-
Hi! I'm trying to create a postCSS plugin for my project with a simple vitejs/postCSS/tailwindcss setup. I have checked the example in the documentation and rewrote the example to work with ES Modules. I saved the code as When I add My
I've tried google, github and chatgpt and was not able to find any example for a custom plugin with that setup. Has any one some experience with that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You need to define relative path (with file extension) if you use custom plugin: export default {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
'./postcss/tailwind-important-last.js': {}
},
} I am not sure, that Vite supports loading ESM plugins right now (since Vite is using CommonJS). Maybe you will need to define plugin in CommonJS and save as |
Beta Was this translation helpful? Give feedback.
You need to define relative path (with file extension) if you use custom plugin:
I am not sure, that Vite supports loading ESM plugins right now (since Vite is using CommonJS). Maybe you will need to define plugin in CommonJS and save as
./postcss/tailwind-important-last.cjs
(and use.cjs
inpostcss.config.js
.