-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
64 lines (60 loc) · 2.02 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
import { getBabelOutputPlugin } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import fs from 'fs';
import path from 'path';
import globImport from 'rollup-plugin-glob-import';
import json from '@rollup/plugin-json';
/**
* Change this to your AE script folder if you would like to autocopy the compiled script to the scripts folder
*
* IMPORTANT: You will need to run as admin to copy to a protected folder (e.g. Program Files)
* No error will be thrown if the copy fails.
*/
const FILE_PATH = 'C:/Program Files/Adobe/Adobe After Effects 2022/Support Files/Scripts/ScriptUI Panels/LoopUtils.jsx';
const config = {
input: ['src/looputils.js'],
external: ["src/**"],
output: {
dir: 'dist',
format: 'iife',
exports: 'default',
name: 'exportedLoopUtils',
},
plugins: [
json(),
globImport(),
commonjs(),
nodeResolve({
include: ["src/**"],
}),
getBabelOutputPlugin({
allowAllFormats: true,
presets: [
[
"@babel/preset-env",
{
modules: false,
}
],
],
}),
{
name: 'Finisher',
async closeBundle() {
if (!FILE_PATH) {
return;
}
if (fs.existsSync(path.dirname(FILE_PATH))) {
fs.appendFile('dist/looputils.js', 'exportedLoopUtils(this);', () => {
fs.copyFile('dist/looputils.js', FILE_PATH, () => undefined);
fs.copyFile('dist/looputils.js', 'build/LoopUtils.jsx', () => undefined);
});
} else {
console.error('ERROR: Cannot find AE script directory. Ensure that the file path in rollup.config is correct.')
}
},
},
],
};
export default config;