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

Commit

Permalink
use es6 syntax, use rollup build
Browse files Browse the repository at this point in the history
  • Loading branch information
steffans committed Jun 16, 2016
1 parent d26732f commit 424b7b7
Show file tree
Hide file tree
Showing 15 changed files with 1,659 additions and 1,065 deletions.
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"license": "MIT",
"ignore": [
".*",
"build",
"*.json",
"*.md"
]
Expand Down
61 changes: 61 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
var fs = require('fs');
var rollup = require('rollup');
var uglify = require('uglify-js');
var babel = require('rollup-plugin-babel');
var string = require('rollup-plugin-string');
var package = require('./package.json');
var version = process.env.VERSION || package.version;
var banner =
"/*!\n" +
" * vue-form v" + version + "\n" +
" * Released under the MIT License.\n" +
" */\n";

rollup.rollup({
entry: 'src/index.js',
plugins: [
string({ include: 'src/**/*.html' }),
babel({ presets: ['es2015-rollup'], plugins: ['transform-object-assign'] })
]
})
.then(function (bundle) {
return write('dist/vue-form.js', bundle.generate({
format: 'umd',
banner: banner,
moduleName: 'VueForm'
}).code, bundle);
})
.then(function (bundle) {
return write('dist/vue-form.min.js',
banner + '\n' + uglify.minify('dist/vue-form.js').code,
bundle);
})
.then(function (bundle) {
return write('dist/vue-form.common.js', bundle.generate({
format: 'cjs',
banner: banner
}).code, bundle);
})
.catch(logError);

function write(dest, code, bundle) {
return new Promise(function (resolve, reject) {
fs.writeFile(dest, code, function (err) {
if (err) return reject(err);
console.log(blue(dest) + ' ' + getSize(code));
resolve(bundle);
});
});
}

function getSize(code) {
return (code.length / 1024).toFixed(2) + 'kb';
}

function logError(e) {
console.log(e);
}

function blue(str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
}
48 changes: 0 additions & 48 deletions build/webpack.build.config.js

This file was deleted.

Loading

0 comments on commit 424b7b7

Please sign in to comment.