69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
// @ts-check
|
|
|
|
import { defineConfig } from "rollup";
|
|
|
|
import commonjs from "@rollup/plugin-commonjs";
|
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
import json from "@rollup/plugin-json";
|
|
import terser from "@rollup/plugin-terser";
|
|
import typescript from "rollup-plugin-typescript2";
|
|
import copy from "rollup-plugin-copy";
|
|
import tsconfigPaths from 'rollup-plugin-tsconfig-paths'
|
|
|
|
/** @type {(options: {matches: RegExp[]}) => import("rollup").Plugin} */
|
|
const excludeImports = (options) => {
|
|
const matches = options.matches;
|
|
return {
|
|
name: "exclude-imports-plugin",
|
|
resolveId(source, importer) {
|
|
if (importer) {
|
|
if (matches.some((r) => r.test(source))) {
|
|
return {
|
|
id: source,
|
|
external: true,
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
};
|
|
};
|
|
|
|
const config = defineConfig(() => {
|
|
const commonPlugs = [
|
|
nodeResolve(),
|
|
commonjs(),
|
|
json(),
|
|
typescript({ check: false }),
|
|
excludeImports({
|
|
matches: [/^gi:/, /^resource:/],
|
|
}),
|
|
// @ts-ignore
|
|
].concat(process.env.DEBUG ? null : terser(), tsconfigPaths());
|
|
|
|
/** @type {import('rollup').RollupOptions} */
|
|
const extensionModule = {
|
|
input: "src/extension.ts",
|
|
output: {
|
|
name: "[name].js",
|
|
dir: "dist",
|
|
format: "es",
|
|
},
|
|
plugins: [
|
|
...commonPlugs,
|
|
copy({
|
|
targets: [
|
|
{
|
|
src: "src/metadata.json",
|
|
dest: "dist",
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
};
|
|
|
|
return [extensionModule];
|
|
});
|
|
|
|
export default config;
|