diff --git a/ui/.gitignore b/ui/.gitignore index 15487fc..573f6a4 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -1,4 +1,3 @@ -/node_modules/ /public/build/ /public/vendor/ diff --git a/ui/.yarnrc.yml b/ui/.yarnrc.yml index 47dc0f4..e59ff12 100644 --- a/ui/.yarnrc.yml +++ b/ui/.yarnrc.yml @@ -1,3 +1 @@ -nodeLinker: node-modules - yarnPath: .yarn/releases/yarn-3.1.0.cjs diff --git a/ui/package.json b/ui/package.json index ccb6d7d..b0fce95 100644 --- a/ui/package.json +++ b/ui/package.json @@ -16,6 +16,8 @@ "@tsconfig/svelte": "^2.0.0", "@types/history": "^4.7.9", "@types/lru-cache": "^5.1.1", + "@yarnpkg/fslib": "^2.6.0", + "@yarnpkg/libzip": "^2.2.2", "postcss": "^8.3.11", "rollup": "^2.59.0", "rollup-plugin-copy": "^3.4.0", @@ -41,7 +43,7 @@ "sirv-cli": "^1.0.0", "sswr": "^1.3.1", "svelte-navigator": "^3.1.5", - "upend": "file:../tools/upend_js" + "upend": "../tools/upend_js" }, "packageManager": "yarn@3.1.0" } diff --git a/ui/rollup.config.js b/ui/rollup.config.js index 418fe78..005cf96 100644 --- a/ui/rollup.config.js +++ b/ui/rollup.config.js @@ -11,6 +11,10 @@ import typescript from "@rollup/plugin-typescript"; import css from "rollup-plugin-css-only"; import dev from "rollup-plugin-dev"; +import pnpapi from "pnpapi"; +import { PosixFS, ZipOpenFS } from "@yarnpkg/fslib"; +import libzip from "@yarnpkg/libzip"; + const production = !process.env.ROLLUP_WATCH; export default { @@ -26,9 +30,20 @@ export default { replace({ "process.env.NODE_ENV": JSON.stringify("production"), }), - svelte({ - preprocess: sveltePreprocess({ sourceMap: !production }), + preprocess: sveltePreprocess({ + sourceMap: !production, + // https://github.com/sveltejs/svelte-preprocess/issues/283#issuecomment-748480431 + scss: { + importer: (url, prev, done) => { + const zipOpenFs = new ZipOpenFS({ libzip: libzip.getLibzipSync() }); + const crossFs = new PosixFS(zipOpenFs); + const res = pnpapi.resolveRequest(url, __dirname + "/"); + const file = crossFs.readFileSync(res); + done({ contents: file.toString() }); + }, + }, + }), compilerOptions: { // enable run-time checks when not in production dev: !production, diff --git a/ui/src/App.svelte b/ui/src/App.svelte index 2640f5b..e61cd66 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -28,9 +28,9 @@