-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrollup.config.js
173 lines (161 loc) · 5.44 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// import hubsTest1 from './src/Apps/HubsTest1/rollup.config.js';
// import hubsTest2 from './src/Apps/HubsTest2/rollup.config.js';
// export default [
// hubsTest1,
// hubsTest2
// ];
import replace from '@rollup/plugin-replace'
import vue from 'rollup-plugin-vue'
//import postcss from 'rollup-plugin-postcss';
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve'
import rollupUrl from '@rollup/plugin-url';
import virtual from '@rollup/plugin-virtual';
import { terser } from "rollup-plugin-terser";
import sourcemaps from 'rollup-plugin-sourcemaps';
//import copy from 'rollup-plugin-copy'
import typescript from '@rollup/plugin-typescript'
import css from 'rollup-plugin-css-only'
//import { writeFileSync } from 'fs';
//import url from 'url';
// import cssImport from "postcss-import"
// import cssUrl from 'postcss-url'
var componentPath
var serverPath
if ((process.env.BUILD !== 'production')) {
componentPath = ""
// your ngrok host name for local testing
serverPath = "https://blair-vue-apps.ngrok.io";
} else {
serverPath = "https://resources.realitymedia.digital";
}
var componentPath = serverPath + '/vue-apps/'
export default [{//["HubsTest1", "HubsTest2"].map((name, index) => ({
//input: ["src/apps/HubsTest1/hubs.js", "src/apps/HubsTest2/hubs.js"],
//input: `src/apps/${name}/hubs.js`,
input: "hubs.ts",
external: ['three'],
context: 'window',
output: [{
dir: 'docs/dist',
//entryFileNames: `${name}-iife.js`,
//entryFileNames: "[name].js",
//assetFileNames: "[name].[ext]",
// manualChunks(id) {
// if (id.includes('node_modules')) {
// return 'vendor';
// }
// },
format: 'iife',
globals: {
three: 'THREE'
},
name: "vueComponents",
sourcemap: 'inline'
},
{
//file: `docs/dist/${name}.min.js`,
file: "docs/dist/hubs.min.js",
//entryFileNames: `${name}.js`,
//entryFileNames: "[name].min.js",
format: 'iife',
globals: {
three: 'THREE'
},
name: "vueComponents",
plugins: [terser()]
}
],
plugins: [
// virtual({
// three: `export default THREE`
// }),
// copy({
// targets: [
// // { src: ['src/assets/theme/fonts/*/*.ttf','src/assets/theme/fonts/*/*.eot','src/assets/theme/fonts/*/*.woff'], dest: 'docs/dist/public/fonts' },
// { src: ['node_modules/reveal.js/dist/*'], dest: 'docs/public/reveal' }
// ],
// verbose: true
// }),
typescript({
typescript: require('typescript'),
}),
rollupPluginNodeResolve(),
rollupUrl({
// by default, rollup-plugin-url will not handle font files
include: ['**/*.svg', '**/*.png', '**/*.jpg', '**/*.gif', '**/*.woff', '**/*.woff2'],
// setting infinite limit will ensure that the files
// are always bundled with the code, not copied to /dist
//limit: Infinity,
limit: 1000,
publicPath: serverPath + '/vue-apps/dist/',
}),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify( 'production' ),
'https://resources.realitymedia.digital/vue-apps/': componentPath,
'var vueComponents = (': 'export const vueComponents = (',
}),
vue({
preprocessStyles: true,
css: false
}),
css({output: "hubs.css"}),
//css(),
// css({
// output: function (styles, styleNodes) {
// const keys = Object.keys(styleNodes);
// keys.forEach((key, index) => {
// let u = new URL ("file://" + key)
// console.log(u)
// let p = u.pathname
// console.log(p)
// let ps = p.split('/')
// console.log(ps)
// console.log(key)
// writeFileSync(key, styleNodes[key])
// })
// }
// }),
// postcss({
// plugins: [
// cssUrl({
// url: "inline", // enable inline assets using base64 encoding
// maxSize: 1000, // maximum file size to inline (in kilobytes)
// publicPath: serverPath + '/vue-apps/dist/',
// })
// cssImport({
// plugins: [
// cssUrl(
// { filter: [
// 'data:*', 'inline'
// ]},
// { filter: [
// // '../../../node_modules/reveal.js/dist/reveal.css',
// // '../../../node_modules/reveal.js/dist/theme/white.css',
// //'src/assets/theme/fonts/**/*.eot', 'src/assets/theme/fonts/**/*.ttf', 'src/assets/theme/fonts/**/*.woff'],
// '*.eot', '*.ttf', '*.woff'],
// url: (asset) => `${serverPath}/vue-apps/dist/public/fonts/${asset.relativePath}`
// }
// )]
// })
// ]
// }),
sourcemaps(),
]
}
// ,
// {
// input: ["room.js", "room-dev-url.js"],
// output: {
// dir: 'docs',
// entryFileNames: "[name].js",
// chunkFileNames: '[name].js',
// format: 'es'
// },
// plugins: [
// replace({
// 'https://resources.realitymedia.digital/vue-apps/': componentPath
// })
// ]
// }
]//))