Skip to content

Commit 23acf9e

Browse files
committedNov 7, 2024
init
0 parents  commit 23acf9e

11 files changed

+2725
-0
lines changed
 

‎.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
test/**/*
2+
# Logs
3+
logs
4+
*.log
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
pnpm-debug.log*
9+
lerna-debug.log*
10+
11+
node_modules
12+
dist
13+
dist-ssr
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

‎index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

‎package-lock.json

+2,551
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "g-motion",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"preview": "vite preview"
10+
},
11+
"devDependencies": {
12+
"@types/node": "^22.9.0",
13+
"@types/react": "^18.3.12",
14+
"@vitejs/plugin-react": "^4.3.3",
15+
"@vitejs/plugin-vue": "^5.1.4",
16+
"typescript": "~5.6.2",
17+
"vite": "^5.4.10"
18+
},
19+
"dependencies": {
20+
"vite-plugin-dts": "^4.3.0"
21+
}
22+
}

‎src/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Import React components
2+
import { Button as ReactButton } from './react/Button';
3+
4+
// Import Vue components
5+
import VueButton from './vue/Button.vue';
6+
7+
// Export conditionally based on the framework, or export all if it’s framework-agnostic
8+
export const ReactComponents = {
9+
Button: ReactButton
10+
};
11+
12+
export const VueComponents = {
13+
Button: VueButton
14+
};
15+
16+
// export default {
17+
// ReactComponents,
18+
// VueComponents
19+
// };

‎src/react/Button.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function Button(props: React.ButtonHTMLAttributes<HTMLButtonElement>) {
2+
return <button {...props} />;
3+
}

‎src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

‎src/vue-shim.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.vue' {
2+
import { DefineComponent } from 'vue';
3+
const component: DefineComponent<{}, {}, any>;
4+
export default component;
5+
}

‎src/vue/Button.vue

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- src/vue/Button.vue -->
2+
<template>
3+
<button>{{ label }}</button>
4+
</template>
5+
6+
<script setup lang="ts">
7+
import { defineComponent } from 'vue';
8+
9+
defineComponent({
10+
name: 'Button',
11+
props: {
12+
label: String
13+
}
14+
});
15+
16+
defineProps<{
17+
label: string;
18+
}>();
19+
</script>

‎tsconfig.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
"jsx": "react-jsxdev",
9+
10+
/* Bundler mode */
11+
"moduleResolution": "Bundler",
12+
"allowImportingTsExtensions": true,
13+
"isolatedModules": true,
14+
"moduleDetection": "force",
15+
"noEmit": true,
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true,
22+
"noUncheckedSideEffectImports": true
23+
},
24+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
25+
}

‎vite.config.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { defineConfig } from 'vite';
2+
import vue from '@vitejs/plugin-vue';
3+
import react from '@vitejs/plugin-react';
4+
import dts from 'vite-plugin-dts';
5+
import { resolve } from 'path';
6+
// import libCss from 'vite-plugin-libcss';
7+
8+
export default defineConfig({
9+
plugins: [
10+
vue(), // Enables Vue SFC support
11+
react(), // Enables React JSX support
12+
dts({
13+
insertTypesEntry: true,
14+
tsconfigPath: './tsconfig.json'
15+
})
16+
],
17+
build: {
18+
copyPublicDir: false,
19+
lib: {
20+
entry: resolve(__dirname, 'src/index.ts'),
21+
name: 'G-Motion',
22+
formats: ['es', 'umd'],
23+
fileName: (format) => `g-motion.${format}.js`
24+
},
25+
rollupOptions: {
26+
external: [
27+
'vue',
28+
'react',
29+
'react-dom',
30+
'react/jsx-runtime' // <-- Add this line to externalize react/jsx-runtime
31+
],
32+
output: {
33+
globals: {
34+
vue: 'Vue',
35+
react: 'React',
36+
'react-dom': 'ReactDOM',
37+
'react/jsx-runtime': 'jsxRuntime'
38+
}
39+
}
40+
}
41+
}
42+
});

0 commit comments

Comments
 (0)
Please sign in to comment.