-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathrollup.config.js
74 lines (71 loc) · 2.02 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
import esbuild from 'rollup-plugin-esbuild'
import resolve from '@rollup/plugin-node-resolve'
import postcss from 'rollup-plugin-postcss'
import commonjs from '@rollup/plugin-commonjs'
import replace from 'rollup-plugin-re'
import image from '@rollup/plugin-image'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'
const browserConfig = {
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning)
}
},
external: ['next', 'react', 'react-dom'],
plugins: [
image(),
postcss({
inject: { insertAt: 'top' },
plugins: [tailwindcss('./tailwind.config.js'), autoprefixer],
}),
commonjs(),
resolve({ preferBuiltins: true }),
esbuild({
sourceMap: process.env.NODE_ENV !== 'production',
minify: process.env.NODE_ENV === 'production',
target: 'es2017',
jsx: 'transform',
}),
],
}
const nodeConfig = {
input: 'server/index.ts',
output: [{ dir: 'build/server/', format: 'cjs' }],
plugins: [
resolve({ preferBuiltins: true }),
replace({
// https://github.com/rollup/rollup-plugin-commonjs/issues/166
// Note: Replace before commonjs
patterns: [
{
match: /formidable(\/|\\)lib/,
test: 'if (global.GENTLY) require = GENTLY.hijack(require);',
replace: '',
},
],
}),
commonjs(),
esbuild({
sourceMap: process.env.NODE_ENV !== 'production',
minify: process.env.NODE_ENV === 'production',
target: 'node10',
}),
],
}
const vanillaConfig = {
...browserConfig,
input: 'client/vanilla/index.tsx',
output: [{ file: 'build/browser/index.js', format: 'cjs' }],
}
const craftConfig = {
...browserConfig,
input: 'client/craft/index.tsx',
output: [{ dir: 'build/browser/craft', format: 'cjs' }],
}
const grapesConfig = {
...browserConfig,
input: 'client/grapes/index.ts',
output: [{ dir: 'build/browser/grapes', format: 'cjs' }],
}
export default [vanillaConfig, craftConfig, grapesConfig, nodeConfig]