demos: move to module only

This commit is contained in:
Philipp Kühn
2021-09-23 22:25:54 +02:00
parent 724b90d8d6
commit c85df80126
5 changed files with 164 additions and 133 deletions

View File

@@ -6,10 +6,11 @@ import {
} from 'path'
import { v4 as uuid } from 'uuid'
import fs from 'fs'
import globby from 'globby'
import { globbySync } from 'globby'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import reactRefresh from '@vitejs/plugin-react-refresh'
import postcss from './postcss.config.js'
// import checker from 'vite-plugin-checker'
const includeDependencies = fs.readFileSync('./includeDependencies.txt')
@@ -23,9 +24,13 @@ export default defineConfig({
include: includeDependencies,
},
css: {
postcss,
},
build: {
rollupOptions: {
input: globby.sync('./**/index.html', {
input: globbySync('./**/index.html', {
ignore: ['dist'],
}),
},
@@ -68,12 +73,10 @@ export default defineConfig({
},
load(id) {
if (id === '@demos') {
const demos = globby
.sync('./src/*/*', { onlyDirectories: true })
const demos = globbySync('./src/*/*', { onlyDirectories: true })
.map(demoPath => {
const name = demoPath.replace('./src/', '')
const tabs = globby
.sync(`./src/${name}/*`, { onlyDirectories: true })
const tabs = globbySync(`./src/${name}/*`, { onlyDirectories: true })
.map(tabPath => ({
name: basename(tabPath),
}))
@@ -99,14 +102,13 @@ export default defineConfig({
load(id) {
if (id.startsWith('source!')) {
const path = id.split('!!')[0].replace('source!', '')
const files = globby
.sync(`${path}/**/*`, {
ignore: [
'**/index.html',
'**/*.spec.js',
'**/*.spec.ts',
],
})
const files = globbySync(`${path}/**/*`, {
ignore: [
'**/index.html',
'**/*.spec.js',
'**/*.spec.ts',
],
})
.map(filePath => {
const name = filePath.replace(`${path}/`, '')
@@ -165,7 +167,7 @@ export default defineConfig({
resolve: {
alias: [
...globby.sync('../packages/*', { onlyDirectories: true })
...globbySync('../packages/*', { onlyDirectories: true })
.map(name => name.replace('../packages/', ''))
.map(name => {
return { find: `@tiptap/${name}`, replacement: resolve(`../packages/${name}/src/index.ts`) }