Vite 2.0.1 isn't invoking my plugins - anything I'm doing wrong? #2133
-
I'm trying to port my snowpack-graphql-plugin to be a Vite plugin. const fileRegex = /\.graphql$/;
export default function graphqlPlugin() {
return {
name: "graphql-plugin",
transform(src, id) {
if (fileRegex.test(id)) {
return {
code: loadToDocumentNodes(src),
map: null, // provide source map if available
};
}
},
};
} and my config file is import { defineConfig } from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
import graphqlPlugin from "./vite.graphql-plugin.js";
export default defineConfig({
plugins: [graphqlPlugin(), reactRefresh()],
build: {
manifest: true,
rollupOptions: {
input: "/assets/js/index.tsx",
},
},
}); and when I run with
I have the above code but whenever I go to http://localhost:3001/queries.graphql it doesn't transform the file at all and if I put a is there anything obvious I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Did you see @rollup/plugin-graphql? https://github.com/rollup/plugins/tree/master/packages/graphql |
Beta Was this translation helpful? Give feedback.
-
I hadn’t! Thank you, I’ll give that a go and see how it goes.
…On Sat, 20 Feb 2021 at 12:53, Matias Capeletto ***@***.***> wrote:
Did you see @rollup/plugin-graphql?
https://github.com/rollup/plugins/tree/master/packages/graphql
It's compatible with Vite
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2133 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAR5JAEETPTWPYEOMJQ3DS76WDXANCNFSM4X52SLSA>
.
|
Beta Was this translation helpful? Give feedback.
-
That plugin works a charm, thanks @matias-capeletto. I realised that vite wouldn't serve the transformed file with either plugin unless you do |
Beta Was this translation helpful? Give feedback.
Did you see @rollup/plugin-graphql? https://github.com/rollup/plugins/tree/master/packages/graphql
It's compatible with Vite