-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
144 lines (134 loc) · 3.67 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { minify } from 'uglify-es';
var surplus = require('./PR/rollup-plugin-surplus/index'), // [!] Pull request in course
eslint = require('rollup-plugin-eslint'),
resolve = require('rollup-plugin-node-resolve'),
uglify = require('rollup-plugin-uglify'),
_outputDir = './build/js';
export default [
APP_CRITICAL_JS(),
APP_MAIN_JS(),
APP_ADDONS_JS(),
DTM_SERVER_JS(),
DTM_USED_CSS_JS(),
DTM_CRITICAL_CSS_JS(),
DTM_STATIC_HTML_JS()
];
function APP_CRITICAL_JS() {
return {
input: './src/app/js/0_critical/critical.index.js',
output: {
name: 'app',
format: 'iife',
file: _outputDir + '/app.critical.js'
},
plugins: front_tasks()
};
}
function APP_ADDONS_JS() {
return {
input: './src/app/js/2_addons/addons.index.js',
output: {
format: 'iife',
file: _outputDir + '/app.addons.js'
},
plugins: front_tasks()
};
}
function APP_MAIN_JS() {
return {
input: './src/app/js/1_app/app.index.js',
output: {
name: 'app',
format: 'iife',
file: _outputDir + '/app.js'
},
plugins: front_tasks()
};
}
function DTM_SERVER_JS() {
return {
input: './dtm/server/dtm-server.index.js',
output: {
file: _outputDir + '/dtm-server.js',
format: 'cjs',
name: 'devserver'
},
plugins: [
eslint(),
resolve({ extensions: ['.js'] }),
uglify(
{
compress: {
sequences: true,
properties: true,
dead_code: true,
drop_debugger: false,
unsafe: false,
conditionals: true,
comparisons: true,
evaluate: true, // [!] disable asm.js if true
booleans: true,
loops: true,
unused: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
side_effects: false,
warnings: true
},
mangle: false,
output: {
beautify: true
}
},
minify // [!] uglify-es
)
]
};
}
function DTM_USED_CSS_JS() {
return {
input: './dtm/front/used_css/js/used_css.index.js',
output: {
name: 'used_css',
format: 'iife',
file: _outputDir + '/tool.used_css.js'
},
plugins: front_tasks()
};
}
function DTM_CRITICAL_CSS_JS() {
return {
input: './dtm/front/critical_css/js/critical_css.index.js',
output: {
name: 'used_css',
format: 'iife',
file: _outputDir + '/tool.critical_css.js'
},
plugins: front_tasks()
};
}
function DTM_STATIC_HTML_JS() {
return {
input: './dtm/front/static_html/js/static_html.index.js',
output: {
name: 'static_html',
format: 'iife',
file: _outputDir + '/tool.static_html.js'
},
plugins: front_tasks()
};
}
// [!] don't share plugins instances
function front_tasks() {
var _tasks = [
eslint(),
surplus(),
resolve({ extensions: ['.js', '.jsx'] })
];
if (process.env.build === 'production') {
_tasks.push(uglify());
}
return _tasks;
}