-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
62 lines (52 loc) · 1.69 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
/**
* Rollup config
*
* Creates the proper static files.
*/
import * as path from 'path'
require('dotenv').config(); // Load environment variables from .env
/////////////////////////////// Rollup plugins ///////////////////////////////
import {terser} from 'rollup-plugin-terser'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import postcss from 'rollup-plugin-postcss'
///////////////////////////////// Constants //////////////////////////////////
const BUILD_DIR = './generated/frontend/morphodict';
// Production mode when debug is false.
const production = !process.env.DEBUG;
/////////////////////////////////// Config ///////////////////////////////////
module.exports = [
{
input: "frontend/index.js",
output: {
file: path.join(BUILD_DIR, "js", "index.js"),
name: null, // The script does not export anything.
format: "iife",
sourcemap: true,
},
plugins: [
resolve(), // finds modules in node_modules
commonjs(), // make rollup understand require() statements
postcss({
// Save the CSS here.
extract: path.join(BUILD_DIR, "css", "styles.css"),
minimize: production,
sourcemap: true,
}),
production && terser(), // minify, but only in production
],
},
{
input: "frontend/click-in-text-embedded-test.js",
output: {
file: path.join(BUILD_DIR, "js", "click-in-text-embedded-test.js"),
name: null, // The script does not export anything.
format: "iife",
sourcemap: true,
},
plugins: [
resolve(), // finds modules in node_modules
commonjs(), // make rollup understand require() statements
]
},
];