1 Star 1 Fork 0

Gitee 极速下载/WizMap

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/poloclub/wizmap
克隆/下载
vite.config.ts 2.84 KB
一键复制 编辑 原始数据 按行查看 历史
Jay Wang 提交于 2023-05-28 16:13 . Add notebook support!
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import * as fs from 'fs';
import * as path from 'path';
// // https://vitejs.dev/config/
// export default defineConfig({
// plugins: [svelte()]
// });
const removeDataDir = () => {
return {
name: 'remove-data-dir',
resolveId(source) {
return source === 'virtual-module' ? source : null;
},
writeBundle(outputOptions, inputOptions) {
const outDir = outputOptions.dir;
const dataDir = path.resolve(outDir, 'data');
fs.rm(dataDir, { recursive: true }, () =>
console.log(`Deleted ${dataDir}`)
);
}
};
};
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
if (command === 'serve') {
// Development
return {
plugins: [svelte()]
};
} else if (command === 'build') {
switch (mode) {
case 'production': {
// Production: standard web page (default mode)
return {
build: {
outDir: 'dist'
},
plugins: [svelte()]
};
}
case 'vercel': {
// Production: for vercel demo
return {
build: {
outDir: 'dist'
},
plugins: [svelte()]
};
}
case 'github': {
// Production: github page
return {
base: '/wizmap/',
build: {
outDir: 'gh-page'
},
plugins: [svelte(), removeDataDir()]
};
}
case 'notebook': {
// Production: notebook widget
return {
build: {
outDir: 'notebook-widget/_wizmap',
sourcemap: false,
lib: {
entry: 'src/main.ts',
formats: ['iife'],
name: 'wizmap',
fileName: format => 'wizmap.js'
}
},
plugins: [
svelte({
emitCss: false
}),
{
name: 'my-post-build-plugin',
writeBundle: {
sequential: true,
order: 'post',
handler(options) {
// Move target file to the notebook package
fs.copyFile(
path.resolve(options.dir, 'wizmap.js'),
path.resolve(__dirname, 'notebook-widget/wizmap/wizmap.js'),
error => {
if (error) throw error;
}
);
// Delete all other generated files
fs.rm(options.dir, { recursive: true }, error => {
if (error) throw error;
});
}
}
}
]
};
}
default: {
console.error(`Unknown production mode ${mode}`);
return null;
}
}
}
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/WizMap.git
git@gitee.com:mirrors/WizMap.git
mirrors
WizMap
WizMap
main

搜索帮助