forked from scaleflex/filerobot-image-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
80 lines (75 loc) · 2.04 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
const pkg = require('./package.json');
const pkgVersion = require('./lerna.json').version;
const now = new Date();
const banner = `/**
* filerobot-image-editor v${pkgVersion}
* ${pkg.repository.url}
* Copyright (c) 2019 ${pkg.author}
* Released under the ${pkg.license} license
* Date: ${now.toISOString()}
*/`;
export default defineConfig(({ mode }) => {
const isProduction = mode === 'production';
const isGithubPagesBuild = process.env.VITE_BUILD_TYPE === 'gh-pages';
console.log(`🕺🏽Running in ${isProduction ? 'Production' : 'Development'}.`);
if (isGithubPagesBuild) {
console.log('⌛ Building GitHub pages demo...');
}
return {
base: './',
publicDir: false,
cacheDir: '.vite',
plugins: [
nodeResolve({
extensions: ['.js', '.jsx', '.json'],
moduleDirectories: [
'./packages/react-filerobot-image-editor/src',
'node_modules',
]
}),
react(
isProduction
? {
babel: {
configFile: true,
ignore: [/node_modules/],
},
}
: {},
),
isProduction && uglify(),
],
server: {
port: 1111,
open: true,
},
build: {
...(isGithubPagesBuild
? {
outDir: './demo-dist',
sourcemap: false,
}
: {
lib: {
entry: './packages/filerobot-image-editor/src/index.js',
fileName: () => 'filerobot-image-editor.min.js',
name: 'FilerobotImageEditor',
formats: ['umd'],
},
minify: 'terser',
terserOptions: {
format: {
comments: false,
preamble: banner,
},
},
outDir: './dist',
sourcemap: 'hidden',
}),
},
};
});