pub async fn export(&mut self) -> Result<(), Arc<Error>> {
        // Note that this function uses different plugin actions from a pure build
        self.plugins
            .functional_actions
            .export_actions
            .before_export
            .run((), self.plugins.get_plugin_data())
            .map_err(|err| Arc::new(err.into()))?;
        let res = self.build_internal(true).await; // We mark that we will be exporting
        if let Err(err) = res {
            let err: Arc<Error> = Arc::new(err.into());
            self.plugins
                .functional_actions
                .export_actions
                .after_failed_build
                .run(err.clone(), self.plugins.get_plugin_data())
                .map_err(|err| Arc::new(err.into()))?;

            return Err(err);
        } else {
            self.plugins
                .functional_actions
                .export_actions
                .after_successful_build
                .run((), self.plugins.get_plugin_data())
                .map_err(|err| Arc::new(err.into()))?;
        }

        // By now, the global states have been written for each locale, along with the
        // render configuration (that's all in memory and in the immutable store)

        // This won't have any trailing slashes (they're stripped by the immutable store
        // initializer)
        let dest = format!("{}/exported", self.immutable_store.get_path());
        // Turn the build artifacts into self-contained static files
        let export_res = self.export_internal().await;
        if let Err(err) = export_res {
            let err: Arc<Error> = Arc::new(err.into());
            self.plugins
                .functional_actions
                .export_actions
                .after_failed_export
                .run(err.clone(), self.plugins.get_plugin_data())
                .map_err(|err| Arc::new(err.into()))?;

            Err(err)
        } else {
            self.copy_static_aliases(&dest)?;
            self.copy_static_dir(&dest)?;

            self.plugins
                .functional_actions
                .export_actions
                .after_successful_export
                .run((), self.plugins.get_plugin_data())
                .map_err(|err| Arc::new(err.into()))?;

            Ok(())
        }
    }
Exports your app to a series of static files. If any templates/capsules
in your app use request-time-only functionality, this will fail.
packages/perseus/src/turbine/export.rs