Skip to content
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

CSS seems like it could be smaller #140

Closed
PaulBGD opened this issue Dec 7, 2016 · 4 comments
Closed

CSS seems like it could be smaller #140

PaulBGD opened this issue Dec 7, 2016 · 4 comments
Labels

Comments

@PaulBGD
Copy link
Member

PaulBGD commented Dec 7, 2016

Currently the outputted CSS contains line breaks and new lines, could we minify this? Example:

Input:

<style>
    h1 {
        color: pink;
    }
</style>

Output:

style.textContent = "                                 \n    h1[svelte-2687689114], [svelte-2687689114] h1 {\n        color: pink;\n    }\n";
@Rich-Harris
Copy link
Member

Yes, it should be minified. Right now it's doing some very light transformation so that styles are scoped, but there's a lot more we could do.

I'll close this issue in favour of #8 as that covers a few different things in addition to minification. The main thing here is that we'd need to add something like PostCSS to parse the CSS and manipulate it properly (and in a way that lets us generate sourcemaps, etc).

@PaulBGD
Copy link
Member Author

PaulBGD commented Dec 7, 2016

Oh my bad, I skimmed that issue but missed the part about minifying.

@Conduitry
Copy link
Member

I realize this ticket is closed but my question seems a bit petty and off-topic for #8 -

What's up with that whitespace at the beginning of the textContent for the inserted style element? Svelte looks like it is specifically adding this, and equal number of spaces as the length into the component .html that the styles started at. This kind of has me scratching my head! The only thing I can think of this possibly being for is somehow aligning the CSS with the source to make debugging easier, but it doesn't really seem to do that even because newlines are treated the same as other characters when deciding how many spaces to add.

@Rich-Harris
Copy link
Member

Oh wow, that's a good point @Conduitry. You're right about the purpose – it was done with sourcemaps in mind, though we don't yet have CSS sourcemaps – but there's no reason to ship it. Reopening this issue to deal with that.

@Rich-Harris Rich-Harris reopened this Dec 15, 2016
Rich-Harris added a commit that referenced this issue Dec 17, 2016
stop prepending CSS with spaces (fixes #140)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants