Skip to content

Commit c56b551

Browse files
committed
refactor: remove example and gulp, upgraded rollup build process, add prettier
1 parent ff1360b commit c56b551

30 files changed

+4611
-26159
lines changed

.prettierrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"useTabs": false,
7+
"printWidth": 80,
8+
"arrowParens": "avoid"
9+
}

build/build.js

-64
This file was deleted.

build/build.rollup.js

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
var fs = require('fs');
2+
var rollup = require('rollup');
3+
var uglify = require('uglify-js');
4+
var buble = require('@rollup/plugin-buble');
5+
var uglify = require('rollup-plugin-uglify').uglify;
6+
var rollupBanner = require('rollup-plugin-banner').default;
7+
var package = require('../package.json');
8+
9+
var banner =
10+
'vue-authenticate v' +
11+
package.version +
12+
'\n' +
13+
'https://github.com/dgrubelic/vue-authenticate\n' +
14+
'Released under the MIT License.\n';
15+
16+
function buildSource(inputOptions, outputOptions) {
17+
rollup.rollup(inputOptions).then(function (bundle) {
18+
return bundle.generate(outputOptions).then(function (output) {
19+
bundle.write(outputOptions);
20+
});
21+
});
22+
}
23+
24+
buildSource(
25+
{
26+
input: 'src/index.js',
27+
plugins: [buble(), rollupBanner(banner)],
28+
},
29+
{
30+
file: 'dist/vue-authenticate.js',
31+
format: 'umd',
32+
name: 'VueAuthenticate',
33+
}
34+
);
35+
36+
buildSource(
37+
{
38+
input: 'src/index.js',
39+
plugins: [buble(), uglify(), rollupBanner(banner)],
40+
},
41+
{
42+
file: 'dist/vue-authenticate.min.js',
43+
format: 'umd',
44+
name: 'VueAuthenticate',
45+
}
46+
);
47+
48+
buildSource(
49+
{
50+
input: 'src/index.js',
51+
plugins: [rollupBanner(banner)],
52+
},
53+
{
54+
file: 'dist/vue-authenticate.esm.js',
55+
format: 'es',
56+
}
57+
);
58+
59+
buildSource(
60+
{
61+
input: 'src/index.js',
62+
plugins: [rollupBanner(banner)],
63+
},
64+
{
65+
file: 'dist/vue-authenticate.common.js',
66+
format: 'cjs',
67+
}
68+
);
69+
70+
// rollup.rollup({
71+
// input: 'src/index.js',
72+
// plugins: [buble()]
73+
// })
74+
// .then(function (bundle) {
75+
// return bundle.write('dist/vue-authenticate.js', bundle.generate({
76+
// format: 'umd',
77+
// banner: banner,
78+
// name: 'VueAuthenticate'
79+
// }).code, bundle);
80+
// })
81+
// .then(function (bundle) {
82+
// return bundle.write('dist/vue-authenticate.min.js',
83+
// banner + '\n' + uglify.minify('dist/vue-authenticate.js').code,
84+
// bundle);
85+
// })
86+
// .then(function (bundle) {
87+
// return bundle.write('dist/vue-authenticate.es2015.js', bundle.generate({
88+
// format: 'es',
89+
// banner: banner,
90+
// footer: 'export { VueAuthenticate };'
91+
// }).code, bundle);
92+
// })
93+
// .then(function (bundle) {
94+
// return bundle.write('dist/vue-authenticate.common.js', bundle.generate({
95+
// format: 'cjs',
96+
// banner: banner
97+
// }).code, bundle);
98+
// })
99+
// .catch(logError);
100+
101+
function write(dest, code, bundle) {
102+
return new Promise(function (resolve, reject) {
103+
fs.writeFile(dest, code, function (err) {
104+
if (err) return reject(err);
105+
console.log(blue(dest) + ' ' + getSize(code));
106+
resolve(bundle);
107+
});
108+
});
109+
}
110+
111+
function getSize(code) {
112+
return (((code && code.length) || 0) / 1024).toFixed(2) + 'kb';
113+
}
114+
115+
function logError(e) {
116+
console.log(e);
117+
}
118+
119+
function blue(str) {
120+
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
121+
}

0 commit comments

Comments
 (0)