Use the same source code to build a website and a native app with ssc.
This uses single-page application architecture & client-side routing. Because route-event listens for clicks on the document.body, URL-based routing will work, even though the native application does not have URLs.
npm start
npm run start-ssc
public
dir is for website, dist
dir is for ssc app
npm run build-web
First compile code to dist
, then run ssc build
, with dist
as the value for copy
in socket.ini
.
npm run build-ssc
npm run build
Note
We are using the --bundle
flag with esbuild
when building for ssc
because trying to use an importmap
in HTML results in this error:
TypeError: Module specifier, '@socketsupply/tonic' does not start with "/", "./", or "../".
Is there a better way to check at runtime if this is running via ssc or browser? We are checking the pathname in index.js
route: location.pathname.includes('Contents/Resources/index.html') ?