-
Notifications
You must be signed in to change notification settings - Fork 56
/
rollup.config.js
65 lines (61 loc) · 1.75 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
import { defineConfig } from "rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { terser } from "rollup-plugin-terser";
import scss from "rollup-plugin-scss";
import { copy } from "@web/rollup-plugin-copy";
import livereload from "rollup-plugin-livereload";
import eslint from "@rollup/plugin-eslint";
const staticFileFolders = ["lang", "packs", "templates"];
/**
* Rollup injects an environment variable if watch mode is used.
* See: https://rollupjs.org/guide/en/#-w--watch
*/
const isWatchMode = !!process.env.ROLLUP_WATCH;
/**
* @type {import('rollup-plugin-livereload').RollupLivereloadOptions & import('livereload').CreateServerConfig}
*/
const livereloadConfig = {
delay: 500,
// need to explicitly exclude the scss entry file to prevent livereload from refreshing the page when the scss changes
// This allows for in-place css updates.
exclusions: [/.*ose\.scss\.js$/],
};
export default defineConfig([
{
input: "src/ose.js",
output: {
dir: "dist/",
format: "es",
sourcemap: true,
},
plugins: [
nodeResolve(),
typescript(),
eslint(),
!isWatchMode && terser(),
copy({
patterns: staticFileFolders.map((folderName) => `${folderName}/**/*`),
rootDir: "./src/",
}),
isWatchMode && livereload(livereloadConfig),
],
},
{
// add a special scss entry point to allow for in place CSS update via livereload
input: "src/ose.scss.js",
output: {
dir: "dist/",
format: "es",
sourcemap: false,
},
plugins: [
scss({
output: "dist/ose.css",
outputStyle: "compressed",
sourceMap: true,
watch: "src/",
}),
],
},
]);