-
Notifications
You must be signed in to change notification settings - Fork 9
/
rollup.config.js
109 lines (102 loc) · 2.59 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import image from '@rollup/plugin-image';
import json from '@rollup/plugin-json';
import { string } from "rollup-plugin-string";
import terser from '@rollup/plugin-terser';
import postcss from 'rollup-plugin-postcss';
import header from "postcss-header";
import cssnano from "cssnano";
import pkg from './package.json';
const PLUGINS_COMMON = [
resolve(), // so Rollup can find libraries
commonjs(), // so Rollup can convert libraries to an ES modules
image({
include: [
"**/assets/**.png",
"**/assets/brushes/**.png",
"**/assets/templates/**.png"
],
exclude: []
}),
string({
include: [
"**/assets/*.svg",
"**/assets/*.csv",
"**/assets/brushes/*.csv",
],
exclude: []
}),
json({
compact: true,
include: [
"**/assets/structures/*.json",
],
exclude: []
})
];
let OUTPUTS = [
{
// browser-friendly UMD build
name: 'SandGameJS',
file: 'dist/sand-game-js.umd.js',
banner: pkg.copyright,
format: 'umd',
sourcemap: true,
}
]
const devBuild = process.env.npm_lifecycle_script.endsWith('-w');
if (devBuild) {
console.log('DEV build');
} else {
console.log('PROD build');
const PLUGINS_MIN = [
terser({
sourceMap: true,
format: {
preamble: pkg.copyright,
comments: false
}
})
];
OUTPUTS.push({
// browser-friendly UMD build, MINIMIZED
name: 'SandGameJS',
file: 'dist/sand-game-js.umd.min.js',
format: 'umd',
sourcemap: true,
plugins: PLUGINS_MIN
});
}
export default [
{
input: 'src/main.js',
plugins: PLUGINS_COMMON,
output: OUTPUTS
},
{
input: 'src/style.css',
plugins: [
postcss({
extract: true,
modules: false,
sourceMap: true,
plugins: [
cssnano({
preset: 'default',
}),
header({
header: pkg.copyright,
})
],
}),
],
output: {
file: 'dist/sand-game-js.css',
},
onwarn(warning, warn) {
if (warning.code === 'FILE_NAME_CONFLICT') return;
warn(warning);
}
},
];