From 7a96eb82c6d860af45e2e787b2308619e0f6769b Mon Sep 17 00:00:00 2001 From: Ian Bouchard Date: Sat, 26 Oct 2024 22:26:22 -0400 Subject: [PATCH] Move PostCSS config into vite.config.js file Fixes #1 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/caido-community/create-plugin/issues/1?shareId=XXXX-XXXX-XXXX-XXXX). --- .../packages/frontend/postcss.config.js | 15 --------------- .../packages/frontend/vite.config.ts | 18 ++++++++++++++++-- .../packages/frontend/postcss.config.js | 15 --------------- .../packages/frontend/vite.config.ts | 18 ++++++++++++++++-- 4 files changed, 32 insertions(+), 34 deletions(-) delete mode 100644 templates/frontend-vanilla/packages/frontend/postcss.config.js delete mode 100644 templates/frontend-vue/packages/frontend/postcss.config.js diff --git a/templates/frontend-vanilla/packages/frontend/postcss.config.js b/templates/frontend-vanilla/packages/frontend/postcss.config.js deleted file mode 100644 index daa1b0f..0000000 --- a/templates/frontend-vanilla/packages/frontend/postcss.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import tailwindcss from "tailwindcss"; -import prefixwrap from "postcss-prefixwrap"; - -import manifest from "../../manifest.json" with { type: "json" }; - -export default { - plugins: [ - // This plugin injects the necessary Tailwind classes - tailwindcss(), - - // This plugin wraps the root element in a unique ID - // This is necessary to prevent styling conflicts between plugins - prefixwrap(`#plugin--${manifest.id}`), - ], -} diff --git a/templates/frontend-vanilla/packages/frontend/vite.config.ts b/templates/frontend-vanilla/packages/frontend/vite.config.ts index 0a53c12..ffa6ae0 100644 --- a/templates/frontend-vanilla/packages/frontend/vite.config.ts +++ b/templates/frontend-vanilla/packages/frontend/vite.config.ts @@ -1,5 +1,8 @@ import { resolve } from "path"; import {defineConfig} from "vite"; +import tailwindcss from "tailwindcss"; +import prefixwrap from "postcss-prefixwrap"; +import manifest from "../../manifest.json" with { type: "json" }; export default defineConfig({ plugins: [], @@ -25,6 +28,17 @@ export default defineConfig({ }, ], }, - define: { 'process.env.NODE_ENV': '"production"' } -}); + define: { 'process.env.NODE_ENV': '"production"' }, + css: { + postcss: { + plugins: [ + // This plugin injects the necessary Tailwind classes + tailwindcss(), + // This plugin wraps the root element in a unique ID + // This is necessary to prevent styling conflicts between plugins + prefixwrap(`#plugin--${manifest.id}`), + ], + }, + }, +}); diff --git a/templates/frontend-vue/packages/frontend/postcss.config.js b/templates/frontend-vue/packages/frontend/postcss.config.js deleted file mode 100644 index daa1b0f..0000000 --- a/templates/frontend-vue/packages/frontend/postcss.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import tailwindcss from "tailwindcss"; -import prefixwrap from "postcss-prefixwrap"; - -import manifest from "../../manifest.json" with { type: "json" }; - -export default { - plugins: [ - // This plugin injects the necessary Tailwind classes - tailwindcss(), - - // This plugin wraps the root element in a unique ID - // This is necessary to prevent styling conflicts between plugins - prefixwrap(`#plugin--${manifest.id}`), - ], -} diff --git a/templates/frontend-vue/packages/frontend/vite.config.ts b/templates/frontend-vue/packages/frontend/vite.config.ts index b5794f6..bdc7ec6 100644 --- a/templates/frontend-vue/packages/frontend/vite.config.ts +++ b/templates/frontend-vue/packages/frontend/vite.config.ts @@ -1,6 +1,9 @@ import { resolve } from "path"; import {defineConfig} from "vite"; import vue from "@vitejs/plugin-vue"; +import tailwindcss from "tailwindcss"; +import prefixwrap from "postcss-prefixwrap"; +import manifest from "../../manifest.json" with { type: "json" }; export default defineConfig({ plugins: [ @@ -28,6 +31,17 @@ export default defineConfig({ }, ], }, - define: { 'process.env.NODE_ENV': '"production"' } -}); + define: { 'process.env.NODE_ENV': '"production"' }, + css: { + postcss: { + plugins: [ + // This plugin injects the necessary Tailwind classes + tailwindcss(), + // This plugin wraps the root element in a unique ID + // This is necessary to prevent styling conflicts between plugins + prefixwrap(`#plugin--${manifest.id}`), + ], + }, + }, +});