chore: replace gulp by a pure rollup based build
This commit is contained in:
parent
294fbefd0a
commit
0d6b89a3ed
16 changed files with 1772 additions and 2573 deletions
|
@ -2,25 +2,50 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
const typescript = require("rollup-plugin-typescript2");
|
||||
const sourcemaps = require("rollup-plugin-sourcemaps");
|
||||
const { terser } = require("rollup-plugin-terser");
|
||||
import copy from "@guanghechen/rollup-plugin-copy";
|
||||
import typescript from "rollup-plugin-typescript2";
|
||||
import sourcemaps from "rollup-plugin-sourcemaps";
|
||||
import styles from "rollup-plugin-styles";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import { distDirectory, name, sourceDirectory } from "./tools/const.js";
|
||||
import { convertJSONToPack } from "./tools/json-pack-tools.js";
|
||||
|
||||
const staticFiles = ["template.json", "system.json", "assets", "fonts", "lang", "templates"];
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
|
||||
/**
|
||||
* @type {import('rollup').RollupOptions}
|
||||
*/
|
||||
const config = {
|
||||
input: "src/module/ds4.ts",
|
||||
input: { [`module/${name}`]: `${sourceDirectory}/module/${name}.ts` },
|
||||
output: {
|
||||
dir: "dist/module",
|
||||
dir: distDirectory,
|
||||
format: "es",
|
||||
sourcemap: true,
|
||||
assetFileNames: "[name].[ext]",
|
||||
},
|
||||
plugins: [
|
||||
sourcemaps(),
|
||||
typescript({}),
|
||||
process.env.NODE_ENV === "production" && terser({ ecma: 2020, keep_fnames: true }),
|
||||
typescript(),
|
||||
styles({
|
||||
mode: ["extract", `css/${name}.css`],
|
||||
url: false,
|
||||
sourceMap: true,
|
||||
minimize: isProduction,
|
||||
}),
|
||||
copy({
|
||||
targets: [
|
||||
{ src: staticFiles.map((file) => `${sourceDirectory}/${file}`), dest: distDirectory },
|
||||
{
|
||||
src: [`${sourceDirectory}/packs/*.json`],
|
||||
dest: `${distDirectory}/packs`,
|
||||
rename: (name) => `${name}.db`,
|
||||
transform: convertJSONToPack,
|
||||
},
|
||||
],
|
||||
}),
|
||||
isProduction && terser({ ecma: 2020, keep_fnames: true }),
|
||||
],
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
export default config;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue