mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-20 16:37:39 +00:00
Move website source/build logic to projects/web
Mostly useful as it moves some of our build logic out of the main project, as that's already pretty noisy!
This commit is contained in:
58
projects/web/rollup.config.js
Normal file
58
projects/web/rollup.config.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import { readFileSync } from "fs";
|
||||
import path from "path";
|
||||
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import url from '@rollup/plugin-url';
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
const input = "src";
|
||||
const requirejs = readFileSync("../../node_modules/requirejs/require.js");
|
||||
|
||||
export default {
|
||||
input: [`${input}/index.tsx`],
|
||||
output: {
|
||||
// Also defined in build.gradle.kts
|
||||
dir: "build/rollup/",
|
||||
|
||||
// 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=20211221" : ""; }
|
||||
});
|
||||
`,
|
||||
format: "amd",
|
||||
preferConst: true,
|
||||
amd: {
|
||||
define: "require",
|
||||
}
|
||||
},
|
||||
context: "window",
|
||||
external: ["copycat/embed"],
|
||||
|
||||
plugins: [
|
||||
typescript(),
|
||||
|
||||
url({
|
||||
include: "**/*.dfpwm",
|
||||
fileName: "[name]-[hash][extname]",
|
||||
publicPath: "/",
|
||||
}),
|
||||
|
||||
{
|
||||
name: "cc-tweaked",
|
||||
async transform(code, file) {
|
||||
// Allow loading files in /mount.
|
||||
const ext = path.extname(file);
|
||||
return ext != '.dfpwm' && path.dirname(file) === path.resolve(`${input}/mount`)
|
||||
? `export default ${JSON.stringify(code)};\n`
|
||||
: null;
|
||||
},
|
||||
},
|
||||
|
||||
terser(),
|
||||
],
|
||||
};
|
Reference in New Issue
Block a user