1 | #!/usr/bin/env node
|
2 | (function () {
|
3 | 'use strict';
|
4 |
|
5 | const {rollup} = require('rollup');
|
6 | const json = require('rollup-plugin-json');
|
7 | const babel = require('rollup-plugin-babel');
|
8 | let cache;
|
9 |
|
10 | const 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 |
|
20 | const backedBuilder$1 = () => {
|
21 | const config = importConfig();
|
22 |
|
23 | return rollup({
|
24 | entry: config.src,
|
25 |
|
26 | cache: cache
|
27 | }).then(bundle => {
|
28 |
|
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 |
|
43 | process.title = 'backed';
|
44 | const commander = require('commander');
|
45 | const {version} = require('package.json');
|
46 |
|
47 | commander
|
48 | .version(version)
|
49 | .option('-b, --build', 'build your app/component')
|
50 | .parse(process.argv);
|
51 |
|
52 | let build = commander.build;
|
53 |
|
54 | if (build) {
|
55 | backedBuilder$1();
|
56 | }
|
57 |
|
58 | }());
|