This repository has been archived by the owner on May 24, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathrollup.config.js
114 lines (100 loc) · 4.25 KB
/
rollup.config.js
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
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import pkg from './package.json';
import postcss from 'rollup-plugin-postcss'
const pluginsConfig = [
postcss({}),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true ,
babelrc: false,
presets: [["@babel/preset-env", { modules: false }], ["react-app", {flow:true}]],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
["@babel/plugin-proposal-optional-chaining", { loose: false }],
["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
["@babel/plugin-proposal-nullish-coalescing-operator", { loose: false }],
"@babel/plugin-proposal-do-expressions"
]
}),
resolve({
// 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'], // Default: ['module', 'main']
// DEPRECATED: use "mainFields" instead
// use "module" field for ES6 module if possible
module: true, // Default: true
// DEPRECATED: use "mainFields" instead
// use "jsnext:main" if possible
// legacy field pointing to ES6 module in third-party libraries,
// deprecated in favor of "pkg.module":
// - see: https://github.com/rollup/rollup/wiki/pkg.module
jsnext: true, // Default: false
// DEPRECATED: use "mainFields" instead
// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6)
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true
// some package.json files have a "browser" field which specifies
// alternative files to load for people bundling for the browser. If
// that's you, either use this option or add "browser" to the
// "mainfields" option, otherwise pkg.browser will be ignored
browser: true, // Default: false
// not all files you want to resolve are .js files
extensions: ['.mjs', '.js', '.jsx', '.json'], // Default: [ '.mjs', '.js', '.json', '.node' ]
// whether to prefer built-in modules (e.g. `fs`, `path`) or
// local ones with the same names
preferBuiltins: false, // Default: true
// Lock the module search in this path (like a chroot). Module defined
// outside this path will be marked as external
jail: '/my/jail/path', // Default: '/'
// Set to an array of strings and/or regexps to lock the module search
// to modules that match at least one entry. Modules not matching any
// entry will be marked as external
only: ['some_module', /^@some_scope\/.*$/], // Default: null
// If true, inspect resolved files to check that they are
// ES2015 modules
modulesOnly: true, // Default: false
// Force resolving for these modules to root's node_modules that helps
// to prevent bundling the same package multiple times if package is
// imported from dependencies.
dedupe: ['react', 'react-dom'], // Default: []
// Any additional options that should be passed through
// to node-resolve
customResolveOptions: {
moduleDirectory: 'js_modules'
}
}), // so Rollup can find `ms`
commonjs() // so Rollup can convert `ms` to an ES module
]
export default [
// browser-friendly UMD build
{
input: 'src/editor/components/Dante/Dante.js',
output: {
name: 'Dante',
file: pkg.browser,
format: 'umd'
},
plugins: pluginsConfig
},
// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
{
input: 'src/editor/components/Dante/Dante.js',
external: ['ms'],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' }
],
plugins: pluginsConfig
}
];