-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
50 lines (46 loc) · 1.56 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
import * as fs from "fs";
import svelte from "rollup-plugin-svelte";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import uglify from "rollup-plugin-uglify";
import replace from "rollup-plugin-replace";
import CleanCSS from "clean-css";
const production = !!process.env.production;
export default {
entry: "src/main.js",
dest: "public/bundle.js",
format: "iife",
moduleName: "app",
sourceMap: true,
plugins: [
svelte({
// we'll extract any component CSS out into
// a separate file — better for performance
css(css) {
if (css === null) css = "";
if (production) css = new CleanCSS().minify(css).styles;
fs.writeFileSync("public/app.css", `/* This file is automatically generated — don't edit it! */\n${css}`);
}
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve(),
babel({
exclude: "node_modules/**" // only transpile our source code
}),
commonjs({
include: ["node_modules/**"]
}),
replace({
"process.env.NODE_ENV": JSON.stringify("development")
}),
// If we're building for production (npm run build
// instead of npm run dev), transpile and minify
production && buble({ exclude: "node_modules/**" }),
production && uglify()
]
};