Skip to content

Commit 457d055

Browse files
committed
Split demo and dist builds
1 parent 8059635 commit 457d055

File tree

3 files changed

+53
-49
lines changed

3 files changed

+53
-49
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
},
1212
"scripts": {
1313
"build": "npm run check && vite build",
14-
"build-demo": "npm run check && vite build --mode=demo",
14+
"build-demo": "npm run check && vite build -c vite.config.demo.ts",
1515
"check": "vue-tsc --build --force && vitest run --coverage && eslint",
16-
"deploy-dev": "wrangler deploy",
17-
"deploy-prod": "wrangler deploy --env=production",
1816
"dev": "vite",
1917
"test": "vitest"
2018
},

vite.config.demo.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import vue from '@vitejs/plugin-vue'
2+
import { defineConfig } from 'vite'
3+
import svg from 'vite-svg-loader'
4+
5+
export default defineConfig({
6+
base: process.env.VITE_BASE_URL,
7+
plugins: [ vue(), svg() ],
8+
build: {
9+
minify: true,
10+
sourcemap: true,
11+
outDir: 'demo',
12+
copyPublicDir: true,
13+
},
14+
})

vite.config.ts

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,46 @@ import dts from 'vite-plugin-dts'
33
import svg from 'vite-svg-loader'
44
import { defineConfig } from 'vitest/config'
55

6-
export default defineConfig((env) => {
7-
const demo = env.mode === 'demo'
6+
export default defineConfig({
7+
plugins: [ vue(), svg(), dts({
8+
tsconfigPath: './tsconfig.app.json',
9+
rollupTypes: true,
10+
}) ],
811

9-
const plugins = [ vue(), svg() ]
10-
if (! demo) {
11-
plugins.push(dts({
12-
tsconfigPath: './tsconfig.app.json',
13-
rollupTypes: ! demo,
14-
}))
15-
}
16-
17-
return defineConfig({
18-
base: demo ? process.env.VITE_BASE_URL : undefined,
19-
plugins,
20-
build: {
21-
minify: true,
22-
sourcemap: true,
23-
outDir: demo ? 'demo' : 'dist',
24-
copyPublicDir: demo,
25-
lib: demo ? undefined :{
26-
formats: [ 'es' ],
27-
entry: 'lib/index.ts',
28-
name: 'JuitTinyEdit',
29-
fileName: 'index',
30-
},
31-
rollupOptions: {
32-
external: [ 'vue' ],
33-
output: {
34-
globals: { vue: 'Vue' },
35-
},
36-
},
12+
build: {
13+
minify: true,
14+
sourcemap: true,
15+
outDir: 'dist',
16+
copyPublicDir: false,
17+
lib: {
18+
formats: [ 'es' ],
19+
entry: 'lib/index.ts',
20+
name: 'JuitTinyEdit',
21+
fileName: 'index',
3722
},
38-
test: {
39-
globals: true,
40-
environment: 'jsdom',
41-
include: [ 'test/**/*.test.ts' ],
42-
coverage: {
43-
provider: 'v8',
44-
reporter: [ 'text', 'html' ],
45-
reportsDirectory: 'coverage',
46-
cleanOnRerun: true,
47-
include: [ 'lib' ],
48-
exclude: [
49-
'lib/**/*.test.ts',
50-
'lib/editor.vue', // we always get 100% coverage???
51-
],
52-
reportOnFailure: true,
23+
rollupOptions: {
24+
external: [ 'vue' ],
25+
output: {
26+
globals: { vue: 'Vue' },
5327
},
5428
},
55-
})
29+
},
30+
31+
test: {
32+
globals: true,
33+
environment: 'jsdom',
34+
include: [ 'test/**/*.test.ts' ],
35+
coverage: {
36+
provider: 'v8',
37+
reporter: [ 'text', 'html' ],
38+
reportsDirectory: 'coverage',
39+
cleanOnRerun: true,
40+
include: [ 'lib' ],
41+
exclude: [
42+
'lib/**/*.test.ts',
43+
'lib/editor.vue', // we always get 100% coverage???
44+
],
45+
reportOnFailure: true,
46+
},
47+
},
5648
})

0 commit comments

Comments
 (0)