-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
50 lines (42 loc) · 1.28 KB
/
Copy pathrollup.config.js
File metadata and controls
50 lines (42 loc) · 1.28 KB
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
import lwc from '@lwc/rollup-plugin';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import run from '@rollup/plugin-run';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dev = process.env.NODE_ENV !== 'production';
const lwcInputDir = path.resolve(__dirname, 'src/client/lwc/');
const lwcInput = path.join(lwcInputDir, 'main.js');
const lwcOutputDir = path.resolve(__dirname, 'src/client/dist/');
const lwcOutput = {
file: path.join(lwcOutputDir, 'index.js'),
format: 'esm'
};
const serverInputDir = path.resolve(__dirname, 'src/server/');
const serverInput = path.join(serverInputDir, 'index.js');
const serverOutputDir = path.resolve(__dirname, 'src/server/dist/');
const serverOutput = {
file: path.join(serverOutputDir, 'index.js'),
format: 'esm'
};
const lwcConfig = {
input: lwcInput,
output: lwcOutput,
plugins: [
resolve(),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
preventAssignment: true
}),
lwc()
],
};
const serverConfig = {
external: ['express', 'path', 'url'],
input: serverInput,
output: serverOutput,
plugins: [dev && run()]
};
export default [lwcConfig, serverConfig];