Skip to content

Commit

Permalink
Split demo and dist builds
Browse files Browse the repository at this point in the history
  • Loading branch information
pfumagalli committed Nov 6, 2024
1 parent 8059635 commit 457d055
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
},
"scripts": {
"build": "npm run check && vite build",
"build-demo": "npm run check && vite build --mode=demo",
"build-demo": "npm run check && vite build -c vite.config.demo.ts",
"check": "vue-tsc --build --force && vitest run --coverage && eslint",
"deploy-dev": "wrangler deploy",
"deploy-prod": "wrangler deploy --env=production",
"dev": "vite",
"test": "vitest"
},
Expand Down
14 changes: 14 additions & 0 deletions vite.config.demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import svg from 'vite-svg-loader'

export default defineConfig({
base: process.env.VITE_BASE_URL,
plugins: [ vue(), svg() ],
build: {
minify: true,
sourcemap: true,
outDir: 'demo',
copyPublicDir: true,
},
})
84 changes: 38 additions & 46 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,46 @@ import dts from 'vite-plugin-dts'
import svg from 'vite-svg-loader'
import { defineConfig } from 'vitest/config'

export default defineConfig((env) => {
const demo = env.mode === 'demo'
export default defineConfig({
plugins: [ vue(), svg(), dts({
tsconfigPath: './tsconfig.app.json',
rollupTypes: true,
}) ],

const plugins = [ vue(), svg() ]
if (! demo) {
plugins.push(dts({
tsconfigPath: './tsconfig.app.json',
rollupTypes: ! demo,
}))
}

return defineConfig({
base: demo ? process.env.VITE_BASE_URL : undefined,
plugins,
build: {
minify: true,
sourcemap: true,
outDir: demo ? 'demo' : 'dist',
copyPublicDir: demo,
lib: demo ? undefined :{
formats: [ 'es' ],
entry: 'lib/index.ts',
name: 'JuitTinyEdit',
fileName: 'index',
},
rollupOptions: {
external: [ 'vue' ],
output: {
globals: { vue: 'Vue' },
},
},
build: {
minify: true,
sourcemap: true,
outDir: 'dist',
copyPublicDir: false,
lib: {
formats: [ 'es' ],
entry: 'lib/index.ts',
name: 'JuitTinyEdit',
fileName: 'index',
},
test: {
globals: true,
environment: 'jsdom',
include: [ 'test/**/*.test.ts' ],
coverage: {
provider: 'v8',
reporter: [ 'text', 'html' ],
reportsDirectory: 'coverage',
cleanOnRerun: true,
include: [ 'lib' ],
exclude: [
'lib/**/*.test.ts',
'lib/editor.vue', // we always get 100% coverage???
],
reportOnFailure: true,
rollupOptions: {
external: [ 'vue' ],
output: {
globals: { vue: 'Vue' },
},
},
})
},

test: {
globals: true,
environment: 'jsdom',
include: [ 'test/**/*.test.ts' ],
coverage: {
provider: 'v8',
reporter: [ 'text', 'html' ],
reportsDirectory: 'coverage',
cleanOnRerun: true,
include: [ 'lib' ],
exclude: [
'lib/**/*.test.ts',
'lib/editor.vue', // we always get 100% coverage???
],
reportOnFailure: true,
},
},
})

0 comments on commit 457d055

Please sign in to comment.