mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🎉 Add function to retrieve caret position
This commit is contained in:
@@ -1,12 +1,61 @@
|
||||
import { resolve } from "node:path";
|
||||
import path from "node:path";
|
||||
import fs from 'node:fs/promises';
|
||||
import { defineConfig } from "vite";
|
||||
import { coverageConfigDefaults } from "vitest/config"
|
||||
import { coverageConfigDefaults } from "vitest/config";
|
||||
|
||||
async function waitFor(timeInMillis) {
|
||||
return new Promise(resolve =>
|
||||
setTimeout(_ => resolve(), timeInMillis)
|
||||
);
|
||||
}
|
||||
|
||||
const wasmWatcherPlugin = (options = {}) => {
|
||||
return {
|
||||
name: "vite-wasm-watcher-plugin",
|
||||
configureServer(server) {
|
||||
server.watcher.add("../resources/public/js/render_wasm.wasm")
|
||||
server.watcher.add("../resources/public/js/render_wasm.js")
|
||||
server.watcher.on("change", async (file) => {
|
||||
if (file.includes("../resources/")) {
|
||||
// If we copy the files immediately, we end
|
||||
// up with an empty .js file (I don't know why).
|
||||
await waitFor(100)
|
||||
// copy files.
|
||||
await fs.copyFile(
|
||||
path.resolve(file),
|
||||
path.resolve('./src/wasm/', path.basename(file))
|
||||
)
|
||||
console.log(`${file} changed`);
|
||||
}
|
||||
});
|
||||
|
||||
server.watcher.on("add", async (file) => {
|
||||
if (file.includes("../resources/")) {
|
||||
await fs.copyFile(
|
||||
path.resolve(file),
|
||||
path.resolve("./src/wasm/", path.basename(file)),
|
||||
);
|
||||
console.log(`${file} added`);
|
||||
}
|
||||
});
|
||||
|
||||
server.watcher.on("unlink", (file) => {
|
||||
if (file.includes("../resources/")) {
|
||||
console.log(`${file} removed`);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
wasmWatcherPlugin()
|
||||
],
|
||||
root: "./src",
|
||||
resolve: {
|
||||
alias: {
|
||||
"~": resolve("./src"),
|
||||
"~": path.resolve("./src"),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
|
||||
Reference in New Issue
Block a user