Skip to content

Instantly share code, notes, and snippets.

@ryansolid
Created July 11, 2020 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryansolid/dbd57322a8ff50d18aeeae0622fc615c to your computer and use it in GitHub Desktop.
Save ryansolid/dbd57322a8ff50d18aeeae0622fc615c to your computer and use it in GitHub Desktop.
Example of Solid plugin for Vite
import { join } from "path";
import { Plugin } from "vite";
import { babel } from "@rollup/plugin-babel";
import { transformFileSync } from "@babel/core";
const presets = ["solid", "@babel/preset-typescript"];
export const solidPlugin: Plugin = {
rollupInputOptions: {
plugins: [
babel({
presets,
babelHelpers: "bundled",
extensions: [".js", ".ts", ".jsx", ".tsx"],
}),
],
},
configureServer: ({ root, app }) => {
app.use(async (ctx, next) => {
if (/\.(t|j)s(x)?$/.test(ctx.path) && !ctx.path.includes("@modules")) {
const result = transformFileSync(join(root, ctx.path), {
presets,
sourceMaps: true,
});
ctx.type = "js";
ctx.body = result.code;
ctx.map = result.map;
return;
}
await next();
});
},
};
@ryansolid
Copy link
Author

This is what you are looking for: https://github.com/amoutonbrady/vite-plugin-solid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment