Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
67 lines (63 loc) · 2.22 KB
/
Copy pathvite.config.js
File metadata and controls
67 lines (63 loc) · 2.22 KB
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
import { readFileSync, writeFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { defineConfig } from 'vite'
// Uppy ships its stylesheet precompiled. The application's theme imports the
// package's CSS from `vendor/`, where `node_modules/@uppy` does not exist, so
// a copy that matches the bundled scripts is kept in the package.
function uppyStyles() {
return {
name: 'fluppy-uppy-styles',
buildStart() {
const require = createRequire(import.meta.url)
const styles = [
'@uppy/core',
'@uppy/dashboard',
'@uppy/webcam',
'@uppy/screen-capture',
'@uppy/audio',
'@uppy/image-editor',
'@uppy/url',
'@uppy/image-generator',
].map((name) => {
const { version } = require(`${name}/package.json`)
const css = readFileSync(
require.resolve(`${name}/css/style.min.css`),
'utf8',
)
.replace(/^@charset "UTF-8";/, '')
.replace(/\/\*# sourceMappingURL=[^*]*\*\//g, '')
return `/* ${name} ${version} */\n${css}`
})
writeFileSync(
'resources/css/uppy.css',
`/* Copied by vite.config.js. Do not edit. */\n${styles.join('\n')}\n`,
)
},
}
}
// One file, as Filament's own components are: what the field loads on demand
// is built into it. Chunks would each be published into the application's
// `public` folder under a name with a hash in it, and the ones an upgrade
// replaces would be left there.
export default defineConfig({
plugins: [uppyStyles()],
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
build: {
outDir: 'resources/dist',
emptyOutDir: true,
sourcemap: false,
minify: true,
lib: {
entry: 'resources/js/index.js',
formats: ['es'],
},
rollupOptions: {
output: {
entryFileNames: 'components/fluppy.js',
inlineDynamicImports: true,
},
},
},
})