-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
91 lines (82 loc) · 2.16 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
import resolve from 'rollup-plugin-node-resolve';
import vue from 'rollup-plugin-vue';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import less from 'rollup-plugin-less';
import copy from 'copy';
import * as dotenv from 'dotenv-flow';
import { terser } from "rollup-plugin-terser";
import progress from 'rollup-plugin-progress';
dotenv.config();
copy(['assets/**/*'], 'dist/static/', {flatten: true}, (e, f) => {
if (e) throw e;
f.forEach( (f) => {
console.log(`Copying to ${f.relative}`);
});
});
let copy2replace = new Promise( (resolve) => {
copy.each(['src/favicon.ico', 'src/index.html', 'src/manifest.webmanifest', 'src/robots.txt', 'src/sw.js'], 'dist/', {flatten: true}, (e, f) => {
if (e) throw e;
resolve(f);
});
});
copy2replace.then( (f) => {
f.forEach( (f) => {
console.log(`Copying to ${f.relative}`);
});
});
const plugins = [
less({
include: 'src/index.less',
output: 'dist/index.css',
option: {
compress: true
}
}),
vue(),
resolve({
browser: true
}),
commonjs({
namedExports: {
'tweetnacl': ['box', 'randomBytes', 'sign'],
'idb': ['openDB']
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.MODE),
'process.env.DEBUG_MODE': process.env.TITLE,
'IWSI': process.env.WS,
'ISRVI': process.env.SRV,
'I-H1-I': process.env.H1,
'I-H2-I': process.env.H2,
'I-H3-I': process.env.H3,
'I-TAGLINE-I': process.env.TAGLINE,
'I-LINKS-I': process.env.LINKS,
'I-WTF-I': process.env.WTF
}),
progress({
clearLine: false // default: true
})
];
let config = {
input: 'src/index.js',
output: {
file: 'dist/index.js',
format: 'es',
//format: 'iife',
sourcemap: true
},
watch: {
include: 'src/**'
},
plugins: plugins
};
if (process.env.MODE == 'production') {
config.output.sourcemap = false;
config.plugins.push(terser({
compress: true,
ecma: 8
}));
};
export default config;