Gathering detailed insights and metrics for vite-plugin-solid
Gathering detailed insights and metrics for vite-plugin-solid
Gathering detailed insights and metrics for vite-plugin-solid
Gathering detailed insights and metrics for vite-plugin-solid
npm install vite-plugin-solid
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
441 Stars
402 Commits
52 Forks
2 Watching
7 Branches
38 Contributors
Updated on 26 Nov 2024
TypeScript (92.09%)
JavaScript (6.09%)
HTML (1.41%)
MDX (0.41%)
Cumulative downloads
Total Downloads
Last day
-25.7%
13,214
Compared to previous day
Last week
-6.2%
79,323
Compared to previous week
Last month
5%
333,966
Compared to previous month
Last year
84.1%
3,833,136
Compared to previous year
3
A simple integration to run solid-js with vite
Join solid discord and check the troubleshooting section to see if your question hasn't been already answered.
.tsx
) out of the boxThis module 100% ESM compatible and requires NodeJS 14.18.0
or later.
You can check your current version of NodeJS by typing node -v
in your terminal. If your version is below that one version I'd encourage you to either do an update globally or use a NodeJS version management tool such as Volta or nvm.
You can use the vite-template-solid starter templates similar to CRA:
1$ npx degit solidjs/templates/js my-solid-project 2$ cd my-solid-project 3$ npm install # or pnpm install or yarn install 4$ npm run start # starts dev-server with hot-module-reloading 5$ npm run build # builds to /dist
Install vite
, vite-plugin-solid
as dev dependencies.
Install solid-js
as dependency.
You have to install those so that you are in control to which solid version is used to compile your code.
1# with npm 2$ npm install -D vite vite-plugin-solid 3$ npm install solid-js 4 5# with pnpm 6$ pnpm add -D vite vite-plugin-solid 7$ pnpm add solid-js 8 9# with yarn 10$ yarn add -D vite vite-plugin-solid 11$ yarn add solid-js
Add it as plugin to vite.config.js
1// vite.config.ts 2import { defineConfig } from 'vite'; 3import solidPlugin from 'vite-plugin-solid'; 4 5export default defineConfig({ 6 plugins: [solidPlugin()], 7});
Just use regular vite
or vite build
commands
1{ 2 "scripts": { 3 "dev": "vite", 4 "build": "vite build" 5 } 6}
A picomatch pattern, or array of patterns, which specifies the files the plugin should operate on.
A picomatch pattern, or array of patterns, which specifies the files to be ignored by the plugin.
This will inject solid-js/dev
in place of solid-js
in dev mode. Has no effect in prod.
If set to false, it won't inject it in dev.
This is useful for extra logs and debug.
This will inject HMR runtime in dev mode. Has no effect in prod. If set to false, it won't inject the runtime in dev.
This will force SSR code in the produced files.
Pass any additional babel transform options. Those will be merged with the transformations required by Solid.
Pass any additional babel-plugin-jsx-dom-expressions. They will be merged with the defaults sets by babel-preset-solid.
Pass any additional @babel/preset-typescript.
An array of custom extension that will be passed through the solid compiler.
By default, the plugin only transform jsx
and tsx
files.
This is useful if you want to transform mdx
files for example.
Starting from version 1.1.0
, this plugin handle automatic HMR via solid-refresh.
At this stage it's still early work but provide basic HMR. In order to get the best out of it there are couple of things to keep in mind:
When you modify a file every state below this component will be reset to default state (including the current file). The state in parent component is preserved.
The entrypoint can't benefit from HMR yet and will force a hard reload of the entire app. This is still really fast thanks to browser caching.
If at least one of this point is blocking to you, you can revert to the old behavior by opting out the automatic HMR and placing the following snippet in your entry point:
1const dispose = render(() => <App />, document.body); 2 3if (import.meta.hot) { 4 import.meta.hot.accept(); 5 import.meta.hot.dispose(dispose); 6}
It appears that Webstorm generate some weird triggers when saving a file. In order to prevent that you can follow this thread and disable the "Safe Write" option in "Settings | Appearance & Behavior | System Settings".
If one of your dependency spit out React code instead of Solid that means that they don't expose JSX properly. To get around it, you might want to manually exclude it from the dependencies optimization
If you are trying to make directives work, and they somehow don't try setting the options.typescript.onlyRemoveTypeImports
option to true
The master branch now target vite 2.
The main breaking change from previous version is that the package has been renamed from @amoutonbrady/vite-plugin-solid
to vite-plugin-solid
.
For other breaking changes, check the migration guide of vite.
If you are using vitest, this plugin already injects the necessary configuration for you. It even automatically detects if you have @testing-library/jest-dom
installed in your project and automatically adds it to the setupFiles
. All you need to add (if you want) is globals
, coverage
, and other testing configuration of your choice. If you can live without those, enjoy using vitest without the need to configure it yourself.
No vulnerabilities found.
No security vulnerabilities found.