-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
41 lines (39 loc) · 1.25 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Helpers
import { defineConfig } from 'vite';
import * as fs from 'fs';
import * as path from 'path';
function copySync (src, dest) {
if (fs.existsSync(src) && fs.statSync(src).isDirectory()) {
fs.mkdirSync(dest, { recursive: true });
fs.readdirSync(src).forEach((childItemName) => {
copySync(path.join(src, childItemName), path.join(dest, childItemName));
});
} else {
fs.mkdirSync(path.dirname(dest), { recursive: true });
fs.copyFileSync(src, dest);
}
}
export default defineConfig({
plugins: [
{
name: 'copy',
generateBundle () {
copySync(path.resolve(__dirname, './src/index.d.ts'), path.resolve(__dirname, './dist/index.d.ts'));
copySync(path.resolve(__dirname, './src/global.css'), path.resolve(__dirname, './dist/global.css'));
copySync(path.resolve(__dirname, './src/variables.css'), path.resolve(__dirname, './dist/variables.css'));
copySync(path.resolve(__dirname, './node_modules/@pixel/fonts/dist'), path.resolve(__dirname, './dist/fonts/pixel-arial'));
}
}
],
publicDir: false,
build: {
lib: {
entry: './src/index.ts',
name: 'Pixel',
formats: ['es'],
fileName: () => 'index.js'
},
emptyOutDir: false,
outDir: './dist'
}
});