import path from 'node:path' // import copy from 'rollup-plugin-copy' import suidPlugin from '@suid/vite-plugin' import devtools from 'solid-devtools/vite' import UnoCSS from 'unocss/vite' import { defineConfig } from 'vite' import { comlink } from 'vite-plugin-comlink' import mkcert from 'vite-plugin-mkcert' import { VitePWA } from 'vite-plugin-pwa' import solidPlugin from 'vite-plugin-solid' // import { gitHMR, gitStatusEnv } from './vite-git-plugin' // import secureNow from 'vite-plugin-secure-now' # certificate revoked error const mkcertPlugin = mkcert() /* {force:true} /* needs to happen once per dev machine */ as any // HACK because typescript otherwise freaks out about.. 'excessive stack depth' export default defineConfig({ define: { // 'import.meta.env.PREV_COMMIT': stringify(gitStatusEnv().PREV_COMMIT), ! - not offline compatible // 'import.meta.env.GIT_STATUS_INFO': stringify(gitStatusEnv().GIT_STATUS_INFO), }, base: './', // allow hosting at sub-path - https://github.com/vitejs/vite/discussions/5081 server: { host: true, // listen on all IPs port: 5173, https: true, // vite-plugin-mkcert does the rest (mkcert({force:true}) needs to happen once) // just add ~/.vite-plugin-mkcert/rootCA.pem to your browser's CA roots - chrome://settings/certificates (authority section) }, preview: { host: true, // listen on all IPs https: true, }, worker: { plugins: () => [ // https://github.com/mathe42/vite-plugin-comlink?tab=readme-ov-file#add-it-to-viteconfigjs comlink(), ], }, plugins: [ // gitHMR, - ! not offline compatible // secureNow({prefix:'note3.localhost'}), comlink(), mkcertPlugin, suidPlugin(), solidPlugin({ // dev: false, }), UnoCSS(), devtools({ /* features options - all disabled by default */ autoname: true, // e.g. enable autoname // TODO: locator & co - https://github.com/thetarnav/solid-devtools/tree/main/packages/main#options }), // // Copy Shoelace assets to dist/shoelace - https://github.com/shoelace-style/rollup-example/blob/master/rollup.config.js // copy({ // copyOnce: true, // targets: [ // { // src: path.resolve(__dirname, 'node_modules/@shoelace-style/shoelace/dist/assets'), // dest: path.resolve(__dirname, 'dist/shoelace'), // }, // ], // }), VitePWA({ devOptions: { // enabled: true, }, registerType: 'prompt', workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg,wasm}'], maximumFileSizeToCacheInBytes: 20000000, // 20MB }, // devOptions: { enabled: true }, // doesn't seem to work includeAssets: [ 'favicon.ico', 'apple-touch-icon-180x180.png', 'maskable-icon-512x512.png', 'commit.txt', // added by CI ], manifest: { name: `Note3${process.env.NODE_ENV === 'development' ? '-dev' : ''}`, short_name: `Note3${process.env.NODE_ENV === 'development' ? '-dev' : ''}`, description: 'Note3 - decentralized woven data PoC', theme_color: '#282c34', icons: [ { src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png', }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', }, ], screenshots: [ { sizes: '906x413', src: 'note3-screenshot-wide.png', form_factor: 'wide', }, { src: 'note3-screenshot-mobile.jpg', sizes: '606x1134', }, ], // https://developer.mozilla.org/en-US/docs/Web/Manifest/display display: 'standalone', // Share from native share selector share_target: { method: 'POST', enctype: 'multipart/form-data', action: '/#/share', params: { title: 'title', text: 'text', url: 'url', }, }, // Protocol handler - https://developer.mozilla.org/en-US/docs/Web/Manifest/protocol_handlers#browser_compatibility protocol_handlers: [ { protocol: 'web+notethree', url: '/#?protocol_handler=%s', // can this be incoming or something more simple? }, ], // ? what for url_handlers ? // url_handlers: [ // { // origin: 'https://note3.app', // }, // ], }, }), ], build: { target: 'esnext', outDir: path.resolve(__dirname, 'dist'), // needed for shoelace - https://github.com/shoelace-style/rollup-example/blob/master/rollup.config.js sourcemap: true, minify: false, // HACK for debugging emptyOutDir: true, rollupOptions: { external: [ // workaround for https://github.com/unocss/unocss/discussions/1953#discussioncomment-4298857 '@iconify/utils/lib/loader/fs', '@iconify/utils/lib/loader/install-pkg', '@iconify/utils/lib/loader/node-loader', '@iconify/utils/lib/loader/node-loaders', ], }, }, })