forked from olton/Metro-UI-CSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.icons.mjs
68 lines (64 loc) · 1.91 KB
/
rollup.icons.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
import {nodeResolve} from '@rollup/plugin-node-resolve'
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 pkg from './package.json' assert {type: "json"}
import fs from "fs";
const production = !(process.env.ROLLUP_WATCH),
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/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
}),
// commonjs(),
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)
}
},
];