layui/vite.config.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-09-27 06:09:33 +08:00
import path from 'path'
import { defineConfig } from 'vite'
import { name } from './package.json'
2021-11-23 11:08:40 +08:00
import babel from '@rollup/plugin-babel'
import plugins from './example/src/plugin/common-plugins'
2021-09-27 06:09:33 +08:00
const camelize = (name: string) =>
name.replace(/(^|-)(\w)/g, (a, b, c) => c.toUpperCase())
2021-09-27 06:09:33 +08:00
export default defineConfig({
2021-11-23 11:08:40 +08:00
root: path.resolve(__dirname, 'example'),
2021-09-27 06:09:33 +08:00
resolve: {
alias: {
'/@src': path.resolve(__dirname, 'src'),
},
},
build: {
target: 'es2015',
outDir: path.resolve(__dirname, 'lib'),
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: camelize(name),
},
2021-09-27 06:09:33 +08:00
rollupOptions: {
output: {
exports: 'named',
globals: (id: string) => {
const name = id.replace(/^@/, '').split('/')[0]
return camelize(name)
},
2021-11-28 18:53:42 +08:00
assetFileNames: 'index.css',
2021-09-27 06:09:33 +08:00
},
plugins: [
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
presets: ['@babel/preset-env', '@babel/preset-typescript'],
}),
],
external: ['vue', 'vue-router'],
2021-09-27 06:09:33 +08:00
},
},
plugins,
2021-11-19 13:09:22 +08:00
})