-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changing svelte preprocess options don't do anything #42
Comments
Related: sveltejs/component-template#8 I'll have to use Note: I think I'll only have to do this preprocess > compile workflow for pages, and Cayo components. (I expect all components used within a page I expect should be preprocessed too?) Something like this might work, which is based on this: // some psuedo code
import { preprocess, compile } from 'svelte/compiler';
import sveltePreprocess from 'svelte-preprocess';
import * as fs from 'fs';
import { Renderer } from './lib/renderer.js';
// pretend we are getting the Template component the same was as the page components below
import { Template } from '/path/to/template.js';
const renderer = new Renderer(Template);
let source = fs.readFile('/path/to/pages/index.svelte');
let preprocessedPage;
await preprocess(source, sveltePreprocess(), { filename: 'Button.svelte' }).then(page => {
const {
js,
css,
warnings,
stats
} = compile(page, {
generate: 'ssr',
dev: true, // probably want this
hydratable: false, // this is default, may need to be changed just fo Cayo components
preserveComments: true, // optional, may be useful for dev
preserveWhitespace: true, // optional, may be useful for dev
});
// do some helpful stuff with warnings and stats
// first arg is the "page" object; page object would have some other stuff too, but for sake of brevity,
// we're just passing the JS class we got from svelte.compile
const content = renderer.render({ js }, config);
// processPage comes next..., etc.
}); This is assuming the dependent code in // render.js: class Renderer
render(page, config) {
const { css: cssOptions } = config;
// const { Component } = page;
const { js: Component } = page;
const { html, css, head } = Component.render();
// do same stuff with html, css, head, etc...
} Also, the way |
Now that we're using rollup, this should be able to be fixed now; just gotta pass the right config options down to the bundle options in |
Related to #37 |
Closing since #37 closed. This should be fixed by the work for that. |
Sounds like this is because cayo used svelte/register, which doesn't support svelte-preprocess: sveltejs/svelte#3690
The text was updated successfully, but these errors were encountered: