|
1 |
| -import { defineConfig } from 'vite' |
2 |
| -import * as path from 'node:path' |
3 |
| -import react from '@vitejs/plugin-react' |
| 1 | +import { defineConfig } from "vite"; |
| 2 | +import * as path from "node:path"; |
| 3 | +import react from "@vitejs/plugin-react"; |
4 | 4 |
|
5 |
| -const isCodeSandbox = 'SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env |
| 5 | +const isCodeSandbox = |
| 6 | + "SANDBOX_URL" in process.env || "CODESANDBOX_HOST" in process.env; |
6 | 7 |
|
7 | 8 | const dev = defineConfig({
|
8 | 9 | plugins: [react()],
|
9 |
| - root: 'example/', |
10 |
| - publicDir: '../public/', |
11 |
| - base: './', |
| 10 | + root: "example/", |
| 11 | + publicDir: "../public/", |
| 12 | + base: "./", |
12 | 13 | server: {
|
13 | 14 | host: true,
|
14 | 15 | open: !isCodeSandbox, // Open if it's not a CodeSandbox
|
15 | 16 | },
|
16 |
| -}) |
| 17 | +}); |
17 | 18 |
|
18 | 19 | const build = defineConfig({
|
19 | 20 | publicDir: false,
|
20 | 21 | build: {
|
21 | 22 | minify: false,
|
22 | 23 | sourcemap: true,
|
23 |
| - target: 'es2018', |
| 24 | + target: "es2018", |
24 | 25 | lib: {
|
25 |
| - formats: ['cjs', 'es'], |
26 |
| - entry: 'src/Ecctrl.tsx', |
27 |
| - fileName: '[name]', |
| 26 | + formats: ["cjs", "es"], |
| 27 | + entry: "src/Ecctrl.tsx", |
| 28 | + fileName: "[name]", |
28 | 29 | },
|
29 | 30 | rollupOptions: {
|
30 |
| - external: (id) => !id.startsWith('.') && !path.isAbsolute(id), |
| 31 | + external: (id) => !id.startsWith(".") && !path.isAbsolute(id), |
31 | 32 | output: {
|
32 | 33 | sourcemapExcludeSources: true,
|
33 | 34 | },
|
34 | 35 | },
|
35 | 36 | },
|
36 |
| - plugins: [ |
37 |
| - { |
38 |
| - name: 'vite-tsc', |
39 |
| - generateBundle(options) { |
40 |
| - const ext = options.format === 'es' ? 'ts' : 'cts' |
41 |
| - this.emitFile({ type: 'asset', fileName: `Ecctrl.d.${ext}`, source: `export * from '../src/Ecctrl.tsx'` }) |
42 |
| - }, |
43 |
| - }, |
44 |
| - ] |
45 |
| -}) |
| 37 | +}); |
46 | 38 |
|
47 |
| -export default process.argv[2] ? build : dev |
| 39 | +export default process.argv[2] ? build : dev; |
0 commit comments