generated from gnikoloff/frontend-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
83 lines (79 loc) · 1.94 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
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import sourcemaps from 'rollup-plugin-sourcemaps'
import copy from 'rollup-plugin-copy'
import css from 'rollup-plugin-import-css'
import typescript from 'rollup-plugin-typescript2'
import json from '@rollup/plugin-json'
import glslify from 'rollup-plugin-glslify'
import replace from '@rollup/plugin-replace'
import { uglify } from 'rollup-plugin-uglify'
import strip from '@rollup/plugin-strip'
import EXAMPLES_DEFINITIONS from './EXAMPLES_DEFINITIONS.json'
console.log({ EXAMPLES_DEFINITIONS })
const plugins = [
css({
minify: process.env.NODE_ENV === 'production',
}),
json(),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
commonjs(),
nodeResolve({
browser: true,
main: true,
}),
typescript({
useTsconfigDeclarationDir: true,
// declarationDir: 'dist/src',
}),
sourcemaps(),
glslify({
include: [
// '**/*.vs',
// '**/*.fs',
// '**/*.vert',
// '**/*.frag',
'**/*.glsl',
'**/*.wglsl',
],
compress: false,
transform: [
[
(shaderPath, shaderSource, shaderOpts) => {
return shaderSource.replace('#define GLSLIFY 1', '')
},
{
post: true,
},
],
],
}),
process.env.NODE_ENV === 'production' && uglify(),
process.env.NODE_ENV === 'production' &&
strip({
include: ['**/*.js', '**/*.ts'],
}),
]
export default [
{
input: 'src/index.js',
output: {
file: 'docs/assets/index.js',
format: 'iife',
},
plugins: [
copy({
targets: [{ src: `src/assets/**/*`, dest: `docs/assets/` }],
}),
],
},
...EXAMPLES_DEFINITIONS.map(({ entries }) => entries)
.flat()
.map(({ id }) => ({
input: `src/examples/${id}/index.ts`,
output: [{ file: `docs/examples/${id}/bundle.js`, format: 'iife' }],
plugins,
})),
]