forked from olton/metroui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
148 lines (144 loc) · 3.88 KB
/
rollup.config.mjs
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
145
146
147
148
import {nodeResolve} from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from "autoprefixer"
import replace from '@rollup/plugin-replace'
import progress from 'rollup-plugin-progress';
import noEmit from 'rollup-plugin-no-emit'
import multi from '@rollup/plugin-multi-entry'
import pkg from './package.json' with {type: "json"}
import fs from "fs";
const production = process.env.MODE === "production",
sourcemap = !production
const banner = `
/*!
* Metro UI v${pkg.version} Components Library (https://metroui.org.ua)
* Copyright 2012-${new Date().getFullYear()} by Serhii Pimenov
* Licensed under MIT
!*/
`
let txt = fs.readFileSync(`source/core/metro.js`, 'utf8')
txt = txt.replace(/version: ".+"/g, `version: "${pkg.version}"`)
txt = txt.replace(/build_time: ".+"/g, `build_time: "${new Date().toLocaleString()}"`)
fs.writeFileSync(`source/core/metro.js`, txt, { encoding: 'utf8', flag: 'w+' })
export default [
{
input: './source/default.js',
watch: {
include: 'source/**',
clearScreen: false
},
plugins: [
progress({
clearLine: true,
}),
replace({
preventAssignment: true,
}),
postcss({
extract: true,
minimize: true,
use: ['less'],
sourceMap: sourcemap,
plugins: [
autoprefixer(),
]
}),
nodeResolve({
browser: true
}),
],
output: {
file: './lib/metro.js',
format: 'iife',
sourcemap,
banner,
plugins: [
terser({
keep_classnames: true,
keep_fnames: true,
})
]
}
},
{
input: './source/icons.js',
watch: {
include: 'source/**',
clearScreen: false
},
plugins: [
progress({
clearLine: true,
}),
replace({
preventAssignment: true,
}),
postcss({
extract: true,
minimize: true,
use: ['less'],
sourceMap: sourcemap,
plugins: [
autoprefixer(),
]
}),
nodeResolve({
browser: true
}),
noEmit({
match(fileName, output) {
return 'icons.js' === fileName
}
}),
],
output: {
dir: './lib',
banner,
},
onwarn: message => {
if (/Generated an empty chunk/.test(message)) return
console.log(message)
}
},
{
input: ['./source/default.js', './source/icons.js'],
watch: {
include: 'source/**',
clearScreen: false
},
plugins: [
progress({
clearLine: true,
}),
multi(),
replace({
preventAssignment: true,
}),
postcss({
extract: false,
minimize: true,
use: ['less'],
sourceMap: false,
plugins: [
autoprefixer(),
]
}),
nodeResolve({
browser: true
}),
],
output: {
file: './lib/metro.all.js',
format: 'iife',
sourcemap: sourcemap,
banner,
plugins: [
terser({
keep_classnames: true,
keep_fnames: true,
})
]
}
},
];