1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-05 03:23:20 +00:00
CC-Tweaked/rollup.config.js
Jonathan Coates 7f3490591d
Some fixes to the web-based emulator
- Bump copy-cat version to have support for initial files in
   directories and the blit fixes.
 - Add an example nft image and move example nfp into a data/ directory.
 - Fix nft parser not resetting colours on the start of each line.
2021-11-27 12:27:40 +00:00

50 lines
1.5 KiB
JavaScript

import { readFileSync } from "fs";
import path from "path";
import typescript from "@rollup/plugin-typescript";
import { terser } from "rollup-plugin-terser";
const input = "src/web";
const requirejs = readFileSync("node_modules/requirejs/require.js");
export default {
input: [`${input}/index.tsx`],
output: {
file: "build/rollup/index.js",
// We bundle requirejs (and config) into the header. It's rather gross
// but also works reasonably well.
// Also suffix a ?v=${date} onto the end in the event we need to require a specific copy-cat version.
banner: `
${requirejs}
require.config({
paths: { copycat: "https://copy-cat.squiddev.cc" },
urlArgs: function(id) { return id == "copycat/embed" ? "?v=20211127" : ""; }
});
`,
format: "amd",
preferConst: true,
amd: {
define: "require",
}
},
context: "window",
external: ["copycat/embed"],
plugins: [
typescript(),
{
name: "cc-tweaked",
async transform(code, file) {
// Allow loading files in /mount.
const ext = path.extname(file);
return ext != '.tsx' && ext != '.ts' && path.dirname(file) === path.resolve(`${input}/mount`)
? `export default ${JSON.stringify(code)};\n`
: null;
},
},
terser(),
],
};