1
|
|
|
/* eslint-disable */ |
2
|
|
|
import path from 'path'; |
3
|
|
|
import resolve from '@rollup/plugin-node-resolve'; |
4
|
|
|
import replace from '@rollup/plugin-replace'; |
5
|
|
|
import alias from '@rollup/plugin-alias'; |
6
|
|
|
import commonjs from '@rollup/plugin-commonjs'; |
7
|
|
|
import json from '@rollup/plugin-json'; |
8
|
|
|
import svelte from 'rollup-plugin-svelte'; |
9
|
|
|
import babel from 'rollup-plugin-babel'; |
10
|
|
|
import {terser} from 'rollup-plugin-terser'; |
11
|
|
|
import config from 'sapper/config/rollup.js'; |
12
|
|
|
import pkg from './package.json'; |
13
|
|
|
|
14
|
|
|
const mode = process.env.NODE_ENV; |
15
|
|
|
const dev = mode === 'development'; |
16
|
|
|
const legacy = !!process.env.SAPPER_LEGACY_BUILD; |
17
|
|
|
|
18
|
|
|
const onwarn = (warning, onwarn) => |
19
|
|
|
(warning.code === 'CIRCULAR_DEPENDENCY' && |
20
|
|
|
/[/\\]@sapper[/\\]/.test(warning.message)) || |
21
|
|
|
onwarn(warning); |
22
|
|
|
const dedupe = (importee) => |
23
|
|
|
importee === 'svelte' || importee.startsWith('svelte/'); |
24
|
|
|
|
25
|
|
|
const aliases = [ |
26
|
|
|
{ find: 'src', replacement: path.resolve(__dirname, 'src') }, |
27
|
|
|
{ find: 'components', replacement: path.resolve(__dirname, 'src/components') }, |
28
|
|
|
{ find: 'normalizer', replacement: path.resolve(__dirname, 'src/normalizer') }, |
29
|
|
|
{ find: 'utils', replacement: path.resolve(__dirname, 'src/utils') }, |
30
|
|
|
{ find: 'store', replacement: path.resolve(__dirname, 'src/store') }, |
31
|
|
|
{ find: 'constants', replacement: path.resolve(__dirname, 'src/constants') }, |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
export default { |
35
|
|
|
client: { |
36
|
|
|
input: config.client.input(), |
37
|
|
|
output: config.client.output(), |
38
|
|
|
plugins: [ |
39
|
|
|
replace({ |
40
|
|
|
'process.browser': true, |
41
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode) |
42
|
|
|
}), |
43
|
|
|
alias({ entries: aliases }), |
44
|
|
|
svelte({ |
45
|
|
|
dev, |
46
|
|
|
hydratable: true, |
47
|
|
|
emitCss: true |
48
|
|
|
}), |
49
|
|
|
resolve({ |
50
|
|
|
browser: true, |
51
|
|
|
dedupe |
52
|
|
|
}), |
53
|
|
|
json(), |
54
|
|
|
commonjs(), |
55
|
|
|
|
56
|
|
|
legacy && |
57
|
|
|
babel({ |
58
|
|
|
extensions: ['.js', '.mjs', '.html', '.svelte'], |
59
|
|
|
runtimeHelpers: true, |
60
|
|
|
exclude: ['node_modules/@babel/**'], |
61
|
|
|
presets: [ |
62
|
|
|
[ |
63
|
|
|
'@babel/preset-env', |
64
|
|
|
{ |
65
|
|
|
targets: '> 0.25%, not dead' |
66
|
|
|
} |
67
|
|
|
] |
68
|
|
|
], |
69
|
|
|
plugins: [ |
70
|
|
|
'@babel/plugin-syntax-dynamic-import', |
71
|
|
|
[ |
72
|
|
|
'@babel/plugin-transform-runtime', |
73
|
|
|
{ |
74
|
|
|
useESModules: true |
75
|
|
|
} |
76
|
|
|
] |
77
|
|
|
] |
78
|
|
|
}), |
79
|
|
|
|
80
|
|
|
!dev && |
81
|
|
|
terser({ |
82
|
|
|
module: true |
83
|
|
|
}) |
84
|
|
|
], |
85
|
|
|
|
86
|
|
|
context: 'this', |
87
|
|
|
onwarn |
88
|
|
|
}, |
89
|
|
|
|
90
|
|
|
server: { |
91
|
|
|
input: config.server.input(), |
92
|
|
|
output: config.server.output(), |
93
|
|
|
plugins: [ |
94
|
|
|
replace({ |
95
|
|
|
'process.browser': false, |
96
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode) |
97
|
|
|
}), |
98
|
|
|
svelte({ |
99
|
|
|
generate: 'ssr', |
100
|
|
|
dev |
101
|
|
|
}), |
102
|
|
|
resolve({ |
103
|
|
|
dedupe |
104
|
|
|
}), |
105
|
|
|
json(), |
106
|
|
|
commonjs(), |
107
|
|
|
alias({ entries: aliases }), |
108
|
|
|
], |
109
|
|
|
external: Object.keys(pkg.dependencies).concat( |
110
|
|
|
require('module').builtinModules || |
111
|
|
|
Object.keys(process.binding('natives')) |
112
|
|
|
), |
113
|
|
|
|
114
|
|
|
onwarn |
115
|
|
|
}, |
116
|
|
|
|
117
|
|
|
serviceworker: { |
118
|
|
|
input: config.serviceworker.input(), |
119
|
|
|
output: config.serviceworker.output(), |
120
|
|
|
plugins: [ |
121
|
|
|
resolve(), |
122
|
|
|
replace({ |
123
|
|
|
'process.browser': true, |
124
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode) |
125
|
|
|
}), |
126
|
|
|
commonjs(), |
127
|
|
|
!dev && terser() |
128
|
|
|
], |
129
|
|
|
|
130
|
|
|
onwarn |
131
|
|
|
} |
132
|
|
|
}; |
133
|
|
|
|