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

feat: export vue compiler options for Tres custom renderer #324

Merged
merged 3 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"scss.lint.unknownAtRules": "ignore",
"css.lint.unknownAtRules": "ignore",
Expand Down
19 changes: 19 additions & 0 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ pnpm add @types/three -D
```
:::

## Vite

If you are using Vite, you have add the following to your `vite.config.ts`:
alvarosabu marked this conversation as resolved.
Show resolved Hide resolved

```ts
import { templateCompilerOptions } from '@tresjs/core'

export default defineConfig({
plugins: [
vue({
// Other config
...templateCompilerOptions
}),
],
}),
```

This is required to make the template compiler work with the custom renderer and not throw warnings on the console. For more info check [here](/guide/troubleshooting.html).

## Try it online

We have a brand new [StackBlitz](https://stackblitz.com/) starter to try TresJS online. Check it out:
Expand Down
8 changes: 3 additions & 5 deletions docs/guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ Got to your `vite.config.ts` and add the following configuration to the `@vitejs
```ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { templateCompilerOptions } from '@tresjs/core'

export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: tag => (tag.startsWith('Tres') && tag !== 'TresCanvas') || tag === 'primitive',
},
},
// Other config
...templateCompilerOptions,
}),
],
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"vite-plugin-inspect": "^0.7.29",
"vite-plugin-require-transform": "^1.0.17",
"vite-svg-loader": "^4.0.0",
"vitepress": "1.0.0-beta.2",
"vitepress": "1.0.0-beta.3",
"vitest": "^0.32.2",
"vue": "^3.3.4",
"vue-demi": "^0.14.5"
Expand Down
2 changes: 1 addition & 1 deletion playground/.eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"watchSyncEffect": true,
"toValue": true
}
}
}
4 changes: 1 addition & 3 deletions playground/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module '@vue/runtime-core' {
declare module 'vue' {
export interface GlobalComponents {
AnimatedModel: typeof import('./src/components/AnimatedModel.vue')['default']
Cameras: typeof import('./src/components/Cameras.vue')['default']
Expand Down
12 changes: 2 additions & 10 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import glsl from 'vite-plugin-glsl'
import UnoCSS from 'unocss/vite'
import { templateCompilerOptions } from '@tresjs/core'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
glsl(),
vue({
script: {
propsDestructure: true,
},
template: {
compilerOptions: {
isCustomElement: tag => (tag.startsWith('Tres') && tag !== 'TresCanvas' && tag !== 'TresLeches') || tag === 'primitive',
},
},
}),
vue(templateCompilerOptions),
AutoImport({
dts: true,
eslintrc: {
Expand Down
Loading