-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
82 lines (74 loc) · 2.52 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
const path = require('path')
const replace = require('rollup-plugin-replace')
const commonjs = require('rollup-plugin-commonjs')
const babel = require('rollup-plugin-babel')
const resolve = require('rollup-plugin-node-resolve')
const fs = require('fs')
module.exports = {
input: path.resolve('./package/index.ts'),
output: {
file: path.resolve(__dirname, './build/mreact.js'),
format: 'umd',
name: 'mreact',
sourcemap: false,
},
// experimentalOptimizeChunks: true,
plugins: [
{
resolveId(source, importer) {
if (path.isAbsolute(source) || path.extname(source)) {
return null
}
let extensions = ['.ts']
let exactPath = path.resolve(importer, '..', source)
for (let i = 0; i < extensions.length; i++) {
let ext = extensions[i]
let resolvedPath = path.join(exactPath, `/index${ext}`)
if (fs.existsSync(resolvedPath)) {
return resolvedPath
}
resolvedPath = exactPath + ext
if (fs.existsSync(resolvedPath)) {
return resolvedPath
}
}
return null
},
},
resolve({}),
babel({
exclude: '/**/node_modules/**',
extensions: ['ts'],
}),
replace({
'process.env': JSON.stringify({
NODE_ENV: 'production',
}),
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: /node_modules/, // Default: undefined
// exclude: ['node_modules/foo/**', 'node_modules/bar/**'], // Default: undefined
// these values can also be regular expressions
// include: /node_modules/
// search for files other than .js files (must already
// be transpiled by a previous plugin!)
extensions: ['.js'], // Default: [ '.js' ]
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourcemap: false, // Default: true
// explicitly specify unresolvable named exports
// (see below for more details)
// namedExports: { './module.js': ['foo', 'bar'] }, // Default: undefined
// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
// ignore: (id) => {
// return id.startsWith('tslib');
// }
}),
],
}