-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
56 lines (49 loc) · 1.17 KB
/
rollup.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
import { nodeResolve } from '@rollup/plugin-node-resolve'
import postcss from 'rollup-plugin-postcss'
import { terser } from 'rollup-plugin-terser'
import { argv } from 'process'
import { pathToFileURL } from 'url'
const url = pathToFileURL('src')
const { href } = url
const watched = argv.includes('-w')
export default [
{
input: 'src/assets/js/main.js',
output: {
file: 'src/assets/js/dist.js',
format: 'es'
},
plugins: [
nodeResolve({
browser: true
}),
{
resolveImportMeta(property, { moduleId }) {
if (property === null || property === 'url') {
const path = pathToFileURL(moduleId).href.replace(href, '')
const url = `new URL('${path}', globalThis.location).href`
if (!property) {
return `{ url: ${url} }`
}
return url
}
return null
}
},
...watched ? [] : [terser()]
]
},
{
input: 'src/assets/css/style.css',
output: {
file: 'src/assets/css/dist.css',
format: 'es'
},
plugins: [
postcss({
extract: true,
minimize: !watched
})
]
}
]