This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
plugins.ts
78 lines (70 loc) · 1.77 KB
/
plugins.ts
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 { Plugin } from 'rollup'
const pluginBabel = require('rollup-plugin-babel')
const pluginNodeResolve = require('rollup-plugin-node-resolve')
const pluginCommonJS = require('rollup-plugin-commonjs')
const pluginImage = require('rollup-plugin-url')
const pluginMarkdown = require('rollup-plugin-md')
const pluginTypescript = require('rollup-plugin-typescript')
const pluginReplace = require('rollup-plugin-replace')
export function pluginInline(filename: string, code: string): Plugin {
return {
name: 'inline',
resolveId(id: string) {
if (id === filename) return filename
return null
},
load(id: string) {
if (id === filename) return code
return null
}
}
}
export const plugins = [
pluginImage({ emitFiles: false }),
pluginMarkdown(),
pluginNodeResolve(),
pluginCommonJS(),
pluginReplace({ 'process.env.NODE_ENV': '"production"' }),
pluginTypescript({
tsconfig: false,
experimentalDecorators: true,
module: 'es2015'
}),
pluginBabel({
presets: [
[
require.resolve('@babel/preset-env'),
{
modules: false,
targets: {
browsers: ['last 2 versions']
}
}
]
],
babelrc: false,
runtimeHelpers: true
})
]
export function pluginCreateVueApp(filename: string, component: string): any {
return {
name: 'Inline',
resolveId(id: string): string | undefined {
if (id === filename) return filename
},
load(id: string): string | undefined {
if (id === filename)
return `
import Component from ${JSON.stringify(component)}
Vue.config.productionTip = false
Vue.config.devtools = false
new Vue({
el: '#app',
render (h) {
return h(Component)
}
})
`
}
}
}