-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run the application in Standalone mode #18
Comments
Standalone is enabled with React and Vue using standalone-single-spa-webpack-plugin. Standalone mode for Angular has not yet been implemented. single-spa Svelte applications created with create-single-spa use Rollup and so the webpack plugin isn't a viable option to integrate. You'd have to write an equivalent plugin for Rollup to accomplish standalone mode. |
It is my humble opinion that create-single-spa generates more problems than it solves. Here's how you can create a Vite + Svelte project using
package.json: "scripts": {
"dev": "vite --mode standalone",
"build": "vite build",
"build-sa": "vite build --mode standalone",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
}, vite.config.ts: import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
export default function (opts) {
console.log('Executing Vite %s in %s mode...', opts.command, opts.mode);
const input = {};
let preserveEntrySignatures: any;
let assetFileNames: string;
if (opts.mode === 'standalone') {
input['index'] = 'index.html';
preserveEntrySignatures = false;
assetFileNames = 'assets/[name]-[hash][extname]';
}
else {
console.log('SPA build.');
input['spa'] = 'src/spa.ts';
preserveEntrySignatures = 'exports-only';
assetFileNames = 'assets/[name][extname]';
}
return defineConfig({
plugins: [svelte()],
build: {
target: 'es2022',
manifest: true,
rollupOptions: {
input,
preserveEntrySignatures,
output: {
exports: 'auto',
assetFileNames
}
}
},
base: '/spa01'
});
}; The last property, Other than that, this is it. No plug-ins needed, and the project is simultaneously a standalone app and a single-spa app. Just run I am writing a series of articles that cover single-spa with Svelte. If you want, you can follow it here. |
I would like to know if you have any example of how to configure the application to run in standalone mode as it works with other frameworks: reactjs, angular vuejs...
The text was updated successfully, but these errors were encountered: