-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
54 lines (48 loc) · 1.29 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
const fs = require("fs");
const path = require("path");
const { transpileModule } = require("typescript");
const tsconfig = require("./tsconfig.json");
const pkg = require("./package.json");
const resolve = {
name: "resolve",
resolveId(file, importer) {
let tmp,
{ ext } = path.parse(file);
if (ext) return file;
let next = path.resolve(path.dirname(importer), file);
if (fs.existsSync(next)) return next;
if (fs.existsSync((tmp = next + ".ts"))) return tmp;
if (fs.existsSync((tmp = next + ".js"))) return tmp;
return null;
},
};
const typescript = {
name: "typescript",
transform(code, file) {
if (!/\.ts$/.test(file)) return code;
// @ts-ignore
let output = transpileModule(code, { ...tsconfig, fileName: file });
return {
code: output.outputText.replace("$$VERSION$$", pkg.version),
map: output.sourceMapText || null,
};
},
};
module.exports = {
input: "src/index.ts",
output: {
format: "cjs",
file: "index.js",
esModule: false,
interop: true,
strict: false,
freeze: false,
},
external: [
...require("module").builtinModules,
...Object.keys(pkg.peerDependencies),
"tailwindcss/lib/util/resolveConfig",
"tailwindcss/lib/util/getAllConfigs",
],
plugins: [resolve, typescript],
};