-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
144 lines (129 loc) · 4.06 KB
/
Copy pathrollup.config.js
File metadata and controls
144 lines (129 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// import cleanup from 'rollup-plugin-cleanup';
// import copy from 'rollup-plugin-cpy';
// https://github.com/mjeanroy/rollup-plugin-prettier
// https://gitlab.com/IvanSanchez/rollup-plugin-file-as-blob
// rollup-plugin-node-globals
// rollup-plugin-async
// rollup-plugin-nodent
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import babel from 'rollup-plugin-babel';
// import json from 'rollup-plugin-json';
import pkg from './package.json';
// import eslint from "rollup-plugin-eslint"
// not all files you want to resolve are .js files
// Default: [ '.mjs', '.js', '.json', '.node' ]
const extensions = ['.js'];
const name = 'JSONFilesValidator';
// packages that should be treated as external dependencies, not bundled
// e.g. ['axios']
const external = [
'@groceristar/sd-wrapper',
'fs',
'path',
'lodash',
'jest-json-schema',
'shelljs',
'jest'
];
// list of plugins used during building process
const plugins = () => [
// Allows node_modules resolution
resolve({
extensions,
// the fields to scan in a package.json to determine the entry point
// if this list contains "browser", overrides specified in "pkg.browser"
// will be used
mainFields: ['module', 'main', 'browser'], // Default: ['module', 'main']
}),
// Allows verification of entry point and all imported files with ESLint.
// @TODO fix and enable eslint for rollup
// eslint({
// /* your options */
// fix:true,
// throwOnWarning:true,
// throwOnError:true
// }),
// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs({
ignore: ['conditional-runtime-dependency'],
}),
// use Babel to compile TypeScript/JavaScript files to ES5
babel({
extensions,
include: ['src/*'],
// ignore node_modules/ in transpilation process
exclude: 'node_modules/**',
// ignore .babelrc (if defined) and use options defined here
// babelrc: false,
// use recommended babel-preset-env without es modules enabled
// and with possibility to set custom targets e.g. { node: '8' }
// presets: [['env', { modules: false, targets }]],
// solve a problem with spread operator transpilation https://github.com/rollup/rollup/issues/281
// plugins: ['babel-plugin-transform-object-rest-spread'],
// removes comments from output
comments: false,
}),
globals(),
builtins(),
// remove flow annotations from output
// flow(),
// copy Flow definitions from source to destination directory
// copy({
// files: ['src/*.flow'],
// dest: 'dist',
// }),
// Allow Rollup to import data from JSON file
// json()
// json({
// include: 'src/data/**',
//
// // for tree-shaking, properties will be declared as
// // variables, using either `var` or `const`
// preferConst: true,
//
// // generate a named export for every property of the JSON object
// namedExports: true // Default: true
//
// })
];
export default {
// source file / entrypoint
input: 'src/index.js',
// output configuration
output: [
{
// output file location
file: pkg.main,
// format of generated JS file, also: esm, and others are available
format: 'cjs',
},
{
// output file location
file: pkg.module,
// format of generated JS file, also: esm, and others are available
format: 'es',
// format: 'esm',
// add sourcemaps
sourcemap: true,
},
{
// output file location
file: pkg.browser,
// format of generated JS file, also: esm, and others are available
format: 'iife',
// name visible for other scripts
name,
// https://rollupjs.org/guide/en#output-globals-g-globals
// globals: {}
},
],
// Specify here external modules which you don't want to
// include in your bundle (for instance: 'lodash', 'moment' etc.)
// https://rollupjs.org/guide/en#external-e-external
external,
// build es modules or commonjs
plugins: plugins(),
};