Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use @preact/preset-vite for Preact templates #2488

Merged
merged 2 commits into from
Mar 16, 2021

Conversation

marvinhagemeister
Copy link
Contributor

@marvinhagemeister marvinhagemeister commented Mar 12, 2021

We've just released a preset for vite so that it's even easier for Preact users to get started with vite. With this we want it to make easier for us to keep the templates up to date and make it less painful for users to upgrade when we add new features to our preset.

Before:

import { defineConfig } from 'vite'
import preactRefresh from '@prefresh/vite'

// https://vitejs.dev/config/
export default defineConfig({
  esbuild: {
    jsxFactory: 'h',
    jsxFragment: 'Fragment',
    jsxInject: `import { h, Fragment } from 'preact'`
  },
  plugins: [preactRefresh()]
})

After:

import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [preact()]
})

See: https://github.com/preactjs/preset-vite

EDIT: Updated for the new preset version which returns an array of plugins now.

antfu
antfu previously approved these changes Mar 13, 2021
@antfu antfu added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 13, 2021
@yyx990803
Copy link
Member

yyx990803 commented Mar 15, 2021

While this is nice, I somewhat would like to keep the convention of "just using plugins". See #2500 (comment) - I believe you can achieve what the preset is doing with a plugin that returns an array of sub plugins.

@PuruVJ
Copy link

PuruVJ commented Mar 15, 2021

Is there a consensus yet about using this method or the proposed presets property?

@marvinhagemeister
Copy link
Contributor Author

@yyx990803 Agree, with your assessment of favoring return an array of plugins. I didn't know this was possible when creating the preset. I'll update the preset to use that and update this PR later today.

Happy to have sparked that discussion and to see that everyone came around to work out a fantastic solution! Love this community!

@marvinhagemeister
Copy link
Contributor Author

@yyx990803 @antfu Published a new version of our preset with your suggested API changes and updated this PR accordingly.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for migrating the preset to a plugin, just tested and it worked great!

This was referenced Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants