You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.1 KiB
67 lines
2.1 KiB
|
3 weeks ago
|
import { cocosPanelConfig, cocosPanel } from '@cocos-fe/vite-plugin-cocos-panel';
|
||
|
|
import vue from '@vitejs/plugin-vue';
|
||
|
|
import { nodeExternals } from 'rollup-plugin-node-externals';
|
||
|
|
import AutoImport from 'unplugin-auto-import/vite';
|
||
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
||
|
|
import Components from 'unplugin-vue-components/vite';
|
||
|
|
import { defineConfig } from 'vite';
|
||
|
|
|
||
|
|
export default defineConfig(({ mode }) => {
|
||
|
|
const isDev = mode === 'development';
|
||
|
|
|
||
|
|
return {
|
||
|
|
build: {
|
||
|
|
lib: {
|
||
|
|
entry: {
|
||
|
|
main: './src/browser/index.ts',
|
||
|
|
panel: './src/panels/panel.ts',
|
||
|
|
},
|
||
|
|
formats: ['cjs'],
|
||
|
|
fileName: (_, entryName) => `${entryName}.cjs`,
|
||
|
|
},
|
||
|
|
watch: isDev
|
||
|
|
? {
|
||
|
|
include: ['./src/**/*.ts', './src/**/*.vue', './src/**/*.css'],
|
||
|
|
}
|
||
|
|
: null,
|
||
|
|
target: 'modules',
|
||
|
|
minify: false,
|
||
|
|
sourcemap: isDev
|
||
|
|
? process.platform === 'win32'
|
||
|
|
? 'inline'
|
||
|
|
: true
|
||
|
|
: false,
|
||
|
|
},
|
||
|
|
plugins: [
|
||
|
|
vue({
|
||
|
|
template: {
|
||
|
|
compilerOptions: {
|
||
|
|
isCustomElement: (tag) => tag.startsWith('ui-'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
nodeExternals({
|
||
|
|
builtins: true,
|
||
|
|
deps: false,
|
||
|
|
devDeps: true,
|
||
|
|
peerDeps: true,
|
||
|
|
optDeps: true,
|
||
|
|
}),
|
||
|
|
cocosPanelConfig(),
|
||
|
|
cocosPanel({
|
||
|
|
transform: (css: string) => {
|
||
|
|
return css.replace(/:root|html\.dark/g, (match) => {
|
||
|
|
return match === ':root' ? ':host' : '#app.dark';
|
||
|
|
});
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
AutoImport({
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
}),
|
||
|
|
Components({
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
};
|
||
|
|
});
|