2017-01-30 19:57:51 +01:00
|
|
|
import {rollup} from 'rollup';
|
2017-01-29 03:20:29 +01:00
|
|
|
import nodeResolve from 'rollup-plugin-node-resolve';
|
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
|
|
|
import babel from 'rollup-plugin-babel';
|
|
|
|
import babelrc from 'babelrc-rollup';
|
2017-06-13 09:16:24 +02:00
|
|
|
import {minify} from 'uglify-es';
|
2017-01-29 21:03:03 +01:00
|
|
|
import fs from 'fs';
|
2017-01-29 03:20:29 +01:00
|
|
|
|
|
|
|
const pkg = require('./package.json');
|
|
|
|
const external = !!pkg.dependencies ? Object.keys(pkg.dependencies) : [];
|
|
|
|
|
2017-01-29 21:03:03 +01:00
|
|
|
/*
|
2017-01-30 19:57:51 +01:00
|
|
|
create the lib for publishing to npm
|
|
|
|
*/
|
2017-01-29 21:03:03 +01:00
|
|
|
|
2017-01-29 03:20:29 +01:00
|
|
|
rollup({
|
2017-01-30 19:57:51 +01:00
|
|
|
entry: 'src/vanilla-tilt.js',
|
|
|
|
plugins: [
|
|
|
|
nodeResolve({
|
2017-02-24 20:45:58 +01:00
|
|
|
module_es2015: true,
|
2017-01-30 19:57:51 +01:00
|
|
|
jsnext: true,
|
|
|
|
main: true,
|
|
|
|
})
|
|
|
|
],
|
|
|
|
external: external
|
|
|
|
}).then(bundle => bundle.write({
|
2017-02-24 20:45:58 +01:00
|
|
|
dest: pkg.module_es2015,
|
2017-01-30 19:57:51 +01:00
|
|
|
format: 'es'
|
|
|
|
})).catch(err => console.log(err.stack));
|
2017-01-29 03:20:29 +01:00
|
|
|
|
2017-01-29 21:03:03 +01:00
|
|
|
rollup({
|
2017-01-30 19:57:51 +01:00
|
|
|
entry: 'src/vanilla-tilt.js',
|
|
|
|
plugins: [
|
|
|
|
nodeResolve({
|
2017-02-24 20:45:58 +01:00
|
|
|
module_es2015: true,
|
2017-01-30 19:57:51 +01:00
|
|
|
jsnext: true,
|
|
|
|
main: true,
|
|
|
|
}),
|
|
|
|
babel(babelrc()),
|
|
|
|
commonjs()
|
|
|
|
],
|
|
|
|
external: external
|
|
|
|
}).then(bundle => bundle.write({
|
|
|
|
dest: pkg.main,
|
|
|
|
format: 'cjs'
|
|
|
|
})).catch(err => console.log(err.stack));
|
2017-01-29 21:03:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2017-01-30 19:57:51 +01:00
|
|
|
create dist for using as script in html
|
|
|
|
*/
|
2017-01-29 03:20:29 +01:00
|
|
|
rollup({
|
2017-01-30 19:57:51 +01:00
|
|
|
entry: 'src/vanilla-tilt.js',
|
|
|
|
plugins: [
|
|
|
|
nodeResolve({
|
2017-02-24 20:45:58 +01:00
|
|
|
module_es2015: true,
|
2017-01-30 19:57:51 +01:00
|
|
|
jsnext: true,
|
|
|
|
main: true,
|
|
|
|
})
|
|
|
|
],
|
|
|
|
external: external
|
|
|
|
}).then((bundle) => {
|
|
|
|
bundle.write({
|
|
|
|
moduleName: 'VanillaTilt',
|
|
|
|
format: 'iife',
|
2017-02-23 23:27:03 +01:00
|
|
|
dest: pkg.distrib,
|
2017-01-30 19:57:51 +01:00
|
|
|
}).then(() => {
|
2017-02-23 23:27:03 +01:00
|
|
|
const code = minify(pkg.distrib, {
|
2017-01-30 19:57:51 +01:00
|
|
|
mangle: {except: ['VanillaTilt']}
|
|
|
|
}).code;
|
|
|
|
|
2017-02-23 23:27:03 +01:00
|
|
|
fs.writeFileSync(pkg.distrib.replace('.js', '.min.js'), code);
|
2017-01-30 19:57:51 +01:00
|
|
|
return bundle;
|
2017-01-29 21:03:03 +01:00
|
|
|
})
|
2017-01-30 19:57:51 +01:00
|
|
|
}).catch(err => console.log(err.stack));
|
2017-01-29 03:20:29 +01:00
|
|
|
|
|
|
|
rollup({
|
|
|
|
entry: 'src/vanilla-tilt.js',
|
|
|
|
plugins: [
|
|
|
|
nodeResolve({
|
2017-02-24 20:45:58 +01:00
|
|
|
module_es2015: true,
|
2017-01-29 03:20:29 +01:00
|
|
|
jsnext: true,
|
|
|
|
main: true
|
|
|
|
}),
|
|
|
|
babel(babelrc()),
|
2017-01-30 20:22:56 +01:00
|
|
|
commonjs()
|
2017-01-29 03:20:29 +01:00
|
|
|
],
|
|
|
|
external: external
|
2017-01-30 19:57:51 +01:00
|
|
|
}).then((bundle) => {
|
2017-02-23 23:27:03 +01:00
|
|
|
const dest = pkg.distrib.replace('.js', '.babel.js');
|
2017-01-29 21:03:03 +01:00
|
|
|
bundle.write({
|
2017-01-30 19:57:51 +01:00
|
|
|
moduleName: 'VanillaTilt',
|
|
|
|
format: 'iife',
|
|
|
|
dest: dest,
|
|
|
|
})
|
2017-01-29 21:03:03 +01:00
|
|
|
.then(() => {
|
|
|
|
const code = minify(dest, {
|
2017-01-30 19:57:51 +01:00
|
|
|
mangle: {except: ['VanillaTilt']}
|
2017-01-29 21:03:03 +01:00
|
|
|
}).code;
|
|
|
|
|
|
|
|
fs.writeFileSync(dest.replace('.js', '.min.js'), code);
|
|
|
|
return bundle;
|
|
|
|
})
|
|
|
|
|
2017-01-30 19:57:51 +01:00
|
|
|
}).catch(err => console.log(err.stack));
|