Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 65d91fa

Browse files
author
Steffan
committed
update build script
1 parent fa669af commit 65d91fa

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The plugin for [Vue.js](http://vuejs.org) provides a declarative way to bind eve
77
- Supports event priorities and [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) based asynchronous events
88
- Supports latest Firefox, Chrome, Safari, Opera and IE9+
99
- Supports Vue 2.0
10-
- Compact size 2KB
10+
- Compact size 3KB (1,5KB gzipped)
1111

1212
## Installation
1313
You can install it via [yarn](https://yarnpkg.com) or [NPM](https://npmjs.org).

build/build.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/* eslint-env node */
22

33
const fs = require('fs');
4+
const zlib = require('zlib');
45
const rollup = require('rollup');
56
const uglify = require('uglify-js');
67
const buble = require('rollup-plugin-buble');
78
const replace = require('rollup-plugin-replace');
8-
const {version} = require('../package.json');
9+
const {name, version, homepage} = require('../package.json');
910
const banner =
1011
'/*!\n' +
11-
' * vue-event-manager v' + version + '\n' +
12-
' * https://github.com/pagekit/vue-event-manager\n' +
12+
' * ' + name + ' v' + version + '\n' +
13+
' * ' + homepage + '\n' +
1314
' * Released under the MIT License.\n' +
1415
' */\n';
1516

@@ -18,40 +19,48 @@ rollup.rollup({
1819
plugins: [buble(), replace({__VERSION__: version})]
1920
})
2021
.then(bundle =>
21-
bundle.generate({
22-
format: 'umd',
23-
banner: banner,
24-
name: 'VueEventManager'
25-
}).then(({code}) => write('dist/vue-event-manager.js', code, bundle))
22+
bundle.generate({
23+
format: 'umd',
24+
banner: banner,
25+
name: 'VueEventManager',
26+
}).then(({code}) => write(`dist/${name}.js`, code, bundle))
2627
)
2728
.then(bundle =>
28-
write('dist/vue-event-manager.min.js', banner + '\n' +
29-
uglify.minify(read('dist/vue-event-manager.js')).code,
30-
bundle)
29+
write(`dist/${name}.min.js`, banner + '\n' +
30+
uglify.minify(read(`dist/${name}.js`)).code, bundle, true)
3131
)
3232
.then(bundle =>
33-
bundle.generate({
34-
format: 'es',
35-
banner: banner
36-
}).then(({code}) => write('dist/vue-event-manager.esm.js', code, bundle))
33+
bundle.generate({
34+
format: 'es',
35+
banner: banner,
36+
}).then(({code}) => write(`dist/${name}.esm.js`, code, bundle))
3737
)
3838
.then(bundle =>
39-
bundle.generate({
40-
format: 'cjs',
41-
banner: banner
42-
}).then(({code}) => write('dist/vue-event-manager.common.js', code, bundle))
39+
bundle.generate({
40+
format: 'cjs',
41+
banner: banner
42+
}).then(({code}) => write(`dist/${name}.common.js`, code, bundle))
4343
)
4444
.catch(logError);
4545

4646
function read(path) {
4747
return fs.readFileSync(path, 'utf8');
4848
}
4949

50-
function write(dest, code, bundle) {
50+
function write(dest, code, bundle, zip) {
5151
return new Promise((resolve, reject) => {
5252
fs.writeFile(dest, code, err => {
5353
if (err) return reject(err);
54-
console.log(blue(dest) + ' ' + getSize(code));
54+
55+
if (zip) {
56+
zlib.gzip(code, (err, zipped) => {
57+
if (err) return reject(err);
58+
console.log(blue(dest) + ' ' + getSize(code) + ' (' + getSize(zipped) + ' gzipped)');
59+
});
60+
} else {
61+
console.log(blue(dest) + ' ' + getSize(code));
62+
}
63+
5564
resolve(bundle);
5665
});
5766
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"unpkg": "dist/vue-event-manager.min.js",
77
"jsdelivr": "dist/vue-event-manager.min.js",
88
"description": "The event manager for Vue.js",
9-
"homepage": "https://github.com/pagekit/vue-event-manager#readme",
9+
"homepage": "https://github.com/pagekit/vue-event-manager",
1010
"license": "MIT",
1111
"keywords": [
1212
"vue",

0 commit comments

Comments
 (0)