Skip to content

Commit

Permalink
Drop inlinejs
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Feb 16, 2024
1 parent 0e281ce commit a5e8430
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
25 changes: 0 additions & 25 deletions .inline.js

This file was deleted.

33 changes: 29 additions & 4 deletions rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import glob from "tiny-glob";
import copy from 'rollup-plugin-copy-glob';
import cjs from "rollup-plugin-cjs-es";
import iife from "rollup-plugin-iife";
import inline from "rollup-plugin-inline-js";
import json from "rollup-plugin-json";
import json from "@rollup/plugin-json";
import output from "rollup-plugin-write-output";
import {terser} from "rollup-plugin-terser";
import terser from "@rollup/plugin-terser";
import resolve from "@rollup/plugin-node-resolve";
import inject from "@rollup/plugin-inject";

Expand Down Expand Up @@ -79,7 +78,7 @@ export default async () => [
},
plugins: [
...commonPlugins(false),
inline()
cleanMessages()
]
}
];
Expand All @@ -92,3 +91,29 @@ function metaDataBlock() {
});
return usm.stringify(meta);
}

function cleanMessages() {
return {
name: "clean-messages",
transform: (code, id) => {
if (!/messages.json/.test(id)) return;

const message = JSON.parse(code);
const newMessage = {};
for (const [key, value] of Object.entries(message)) {
if (value.placeholders) {
value.message = value.message.replace(/\$\w+\$/g, m => {
const name = m.slice(1, -1).toLowerCase();
return value.placeholders[name].content;
});
}
if (/^options/.test(key)) {
newMessage[key] = value.message;
} else if (/^pref/.test(key)) {
newMessage[key[4].toLowerCase() + key.slice(5)] = value.message;
}
}
return JSON.stringify(newMessage, null, 2);
}
}
}

0 comments on commit a5e8430

Please sign in to comment.