-
Notifications
You must be signed in to change notification settings - Fork 26
/
rollup.config.js
78 lines (76 loc) · 1.98 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import alias from '@rollup/plugin-alias'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import image from '@rollup/plugin-image'
import postcss from 'rollup-plugin-postcss'
import vue from 'rollup-plugin-vue'
import esbuild from 'rollup-plugin-esbuild'
import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
import filesize from 'rollup-plugin-filesize'
import requireContext from 'rollup-plugin-require-context'
import { visualizer } from 'rollup-plugin-visualizer'
import scriptSetup from 'unplugin-vue2-script-setup/rollup'
const production = !process.env.ROLLUP_WATCH
const port = 3000
export default {
input: 'src/main.js',
output: {
dir: 'public/assets',
entryFileNames: 'app.js',
format: 'iife',
sourcemap: !production ? 'inline' : false,
name: 'app',
},
plugins: [
json(),
alias({
entries: [{ find: '@', replacement: __dirname + '/src/' }],
}),
image(),
postcss({ extract: 'app.css', config: { path: 'postcss.config.js' } }),
requireContext(),
nodeResolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
scriptSetup(),
vue({
css: false,
needMap: false,
template: {
compilerOptions: {
isCustomElement: (tag) => tag.includes('-'),
},
},
}),
replace({
'process.env.NODE_ENV': production ? '"production"' : '"development"',
preventAssignment: true,
}),
esbuild({
minify: production,
target: 'es2015',
}),
!production &&
visualizer({
open: false,
}),
!production &&
serve({
open: true,
contentBase: 'public',
historyApiFallback: true,
port,
}),
!production && livereload({ watch: 'public' }),
production && filesize(),
],
watch: {
clearScreen: true,
},
}