UNPKG

1.21 kBJavaScriptView Raw
1#!/usr/bin/env node
2(function () {
3'use strict';
4
5const {rollup} = require('rollup');
6const json = require('rollup-plugin-json');
7const babel = require('rollup-plugin-babel');
8let cache;
9
10const importConfig = () => {
11 let config;
12 try {
13 config = require('backed.json');
14 return config;
15 } catch (error) {
16 return console.warn('Backed::backed.json not found, checkout https://github.com/basicelements/backed-cli for more info');
17 }
18};
19
20const backedBuilder$1 = () => {
21 const config = importConfig();
22
23 return rollup({
24 entry: config.src,
25 // Use the previous bundle as starting point.
26 cache: cache
27 }).then(bundle => {
28 // Cache our bundle for later use (optional)
29 cache = bundle;
30
31 bundle.write({
32 format: config.format || 'es',
33 sourceMap: config.sourceMap || true,
34 plugins: [
35 json(),
36 babel()
37 ],
38 dest: config.dest
39 });
40 });
41};
42
43process.title = 'backed';
44const commander = require('commander');
45const {version} = require('package.json');
46
47commander
48 .version(version)
49 .option('-b, --build', 'build your app/component')
50 .parse(process.argv);
51
52let build = commander.build;
53
54if (build) {
55 backedBuilder$1();
56}
57
58}());