diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-06 11:25:05 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-06 11:25:05 -0300 |
commit | 5969a44391f32d931d0b26416fb3e1528f4a32a2 (patch) | |
tree | 3d8e122200e30b4433ca7c3518e49d0d42734034 /packages/demobank-ui/build.mjs | |
parent | d3a6544bc5fd7b3d2d65494ba1c3155b024a436e (diff) | |
download | wallet-core-5969a44391f32d931d0b26416fb3e1528f4a32a2.tar.xz |
using web-utils in demobank
Diffstat (limited to 'packages/demobank-ui/build.mjs')
-rwxr-xr-x | packages/demobank-ui/build.mjs | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/packages/demobank-ui/build.mjs b/packages/demobank-ui/build.mjs index 63ddc1f25..c93b4eb67 100755 --- a/packages/demobank-ui/build.mjs +++ b/packages/demobank-ui/build.mjs @@ -18,9 +18,9 @@ import esbuild from "esbuild"; import path from "path"; import fs from "fs"; -import crypto from "crypto"; -import { sassPlugin } from "esbuild-sass-plugin"; +import sass from "sass"; +// eslint-disable-next-line no-undef const BASE = process.cwd(); const preact = path.join( @@ -44,14 +44,16 @@ const preactCompatPlugin = { }, }; -const entryPoints = ["src/index.tsx"]; +const entryPoints = ["src/index.tsx", "src/stories.tsx"]; let GIT_ROOT = BASE; while (!fs.existsSync(path.join(GIT_ROOT, ".git")) && GIT_ROOT !== "/") { GIT_ROOT = path.join(GIT_ROOT, "../"); } if (GIT_ROOT === "/") { + // eslint-disable-next-line no-undef console.log("not found"); + // eslint-disable-next-line no-undef process.exit(1); } const GIT_HASH = GIT_ROOT === "/" ? undefined : git_hash(); @@ -86,6 +88,26 @@ function copyFilesPlugin(options) { }; } +const DEFAULT_SASS_FILTER = /\.(s[ac]ss|css)$/ + +const buildSassPlugin = { + name: "custom-build-sass", + setup(build) { + + build.onLoad({ filter: DEFAULT_SASS_FILTER }, ({ path: file }) => { + const resolveDir = path.dirname(file) + const { css: contents } = sass.compile(file, { loadPaths: ["./"] }) + + return { + resolveDir, + loader: 'css', + contents + } + }); + + }, +}; + export const buildConfig = { entryPoints: [...entryPoints], bundle: true, @@ -95,6 +117,10 @@ export const buildConfig = { ".svg": "file", ".png": "dataurl", ".jpeg": "dataurl", + '.ttf': 'file', + '.woff': 'file', + '.woff2': 'file', + '.eot': 'file', }, target: ["es6"], format: "esm", @@ -108,17 +134,14 @@ export const buildConfig = { }, plugins: [ preactCompatPlugin, - sassPlugin(), copyFilesPlugin([ { - src: "static/index.html", - dest: "dist/index.html", + src: "./src/index.html", + dest: "./dist/index.html", }, ]), + buildSassPlugin ], }; -esbuild.build(buildConfig).catch((e) => { - console.log(e); - process.exit(1); -}); +await esbuild.build(buildConfig) |