From ecd69a752ec73d6ec1a2da98307d331e439226ef Mon Sep 17 00:00:00 2001 From: zjxxxxxxxxx <954270063@qq.com> Date: Sat, 23 Sep 2023 22:17:49 +0800 Subject: [PATCH] chore: add playground --- README.md | 147 +++++++++++++++--- examples/rollup/src/App.vue | 2 +- examples/rollup/src/components/HelloWorld.tsx | 3 + examples/rollup/src/style.css | 40 ----- examples/vite/src/App.vue | 2 +- examples/vite/src/components/HelloWorld.tsx | 3 + examples/vite/src/style.css | 40 ----- examples/webpack/src/App.vue | 2 +- .../webpack/src/components/HelloWorld.tsx | 3 + examples/webpack/src/style.css | 40 ----- 10 files changed, 135 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index 9886545..88967aa 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ jsx without ```tsx // src/App.tsx export default function App() { - return
hello word
+ return
hello word
; } ``` @@ -49,7 +49,7 @@ with ```tsx // src/App.tsx export default function App() { - return
hello word
+ return
hello word
; } ``` @@ -68,13 +68,13 @@ The bad news is that for `jsx` syntax support, you can't use it with [jsx-vue2]( ```ts // main.ts import Vue from 'vue'; -import VueSource from "unplugin-vue-source/vue"; -import App from "./App.vue"; +import VueSource from 'unplugin-vue-source/vue'; +import App from './App.vue'; Vue.use(VueSource); new Vue({ - el: "#app", + el: '#app', render: (h) => h(App), }); ``` @@ -84,12 +84,12 @@ new Vue({ ```ts // main.ts import { createApp } from 'vue'; -import VueSource from "unplugin-vue-source/vue"; -import App from "./App.vue"; +import VueSource from 'unplugin-vue-source/vue'; +import App from './App.vue'; const app = createApp(App); app.use(VueSource); -app.mount("#app"); +app.mount('#app'); ``` ## Plugins @@ -101,11 +101,13 @@ You need to make sure that `VueSource` is executed before vue compiles the plugi ```ts // vite.config.ts -import VueSource from "unplugin-vue-source/vite"; +import VueSource from 'unplugin-vue-source/vite'; export default defineConfig({ plugins: [ - VueSource({ /* options */ }), + VueSource({ + /* options */ + }), // other plugins ], }); @@ -118,11 +120,13 @@ export default defineConfig({ ```ts // rollup.config.js -import VueSource from "unplugin-vue-source/rollup"; +import VueSource from 'unplugin-vue-source/rollup'; export default { plugins: [ - VueSource({ /* options */ }), + VueSource({ + /* options */ + }), // other plugins ], }; @@ -137,7 +141,9 @@ export default { // webpack.config.js module.exports = { plugins: [ - require("unplugin-vue-source/webpack")({ /* options */ }), + require('unplugin-vue-source/webpack')({ + /* options */ + }), // other plugins ], }; @@ -152,7 +158,9 @@ module.exports = { // rspack.config.js module.exports = { plugins: [ - require("unplugin-vue-source/rspack")({ /* options */ }), + require('unplugin-vue-source/rspack')({ + /* options */ + }), // other plugins ], }; @@ -168,7 +176,9 @@ module.exports = { module.exports = { configureWebpack: { plugins: [ - require("unplugin-vue-source/webpack")({ /* options */ }), + require('unplugin-vue-source/webpack')({ + /* options */ + }), // other plugins ], }, @@ -182,20 +192,22 @@ module.exports = { ```ts // esbuild.config.js -import { build } from "esbuild"; -import VueSource from "unplugin-vue-source/esbuild"; +import { build } from 'esbuild'; +import VueSource from 'unplugin-vue-source/esbuild'; -build({ +build({ plugins: [ - VueSource({ /* options */ }), + VueSource({ + /* options */ + }), // other plugins ], }); ```
- - ## Configuration + +## Configuration The following show the default values of the configuration @@ -203,8 +215,95 @@ The following show the default values of the configuration VueSource({ // source root path root: process.cwd(), - + // generate sourceMap sourceMap: false, -}) -``` \ No newline at end of file +}); +``` + +## Playground + + + + + + + + + + + + + + + + + + + + + +
Rollup + Vue2 + + Source + + + + CodeSandbox + + + + StackBlitz + +
Vite + Vue3 + + Source + + + + CodeSandbox + + + + StackBlitz + +
Webpack + Vue3 + + Source + + + + CodeSandbox + + + + StackBlitz + +
diff --git a/examples/rollup/src/App.vue b/examples/rollup/src/App.vue index 4793c97..9700611 100644 --- a/examples/rollup/src/App.vue +++ b/examples/rollup/src/App.vue @@ -19,7 +19,7 @@ export default Vue.extend({ - + diff --git a/examples/rollup/src/components/HelloWorld.tsx b/examples/rollup/src/components/HelloWorld.tsx index a45ffa4..9902618 100644 --- a/examples/rollup/src/components/HelloWorld.tsx +++ b/examples/rollup/src/components/HelloWorld.tsx @@ -6,6 +6,9 @@ export default defineComponent({ return (

{this.msg}

+

+ Inspect the element to see the __source +

- +