Sapper: %sapper.scripts% can contain non-JS files

Created on 4 Mar 2018  路  2Comments  路  Source: sveltejs/sapper

Moving this from https://github.com/sveltejs/sapper/issues/116#issuecomment-370153344 since that issue is closed by #153. If webpack emits non-JS assets for a route, Sapper will still generate a <script> tag for them:

<script src='/client/123xyz/main.css'></script>
bug

Most helpful comment

I'm currently running into this, getting things like <script src=/client/fbd4e5d87f8d7dec1966/main.0.css> injected into the page when attempting to set up mini-css-extract-plugin to generate a global css file.

Expanding upon this, I also need to inject that CSS file into the head as a <link>. I'm using sapper-template as the base, which currently has no pre-defined CSS processing beyond what svelte provides. I've openned an issue about it there: https://github.com/sveltejs/sapper-template/issues/59

All 2 comments

I'm currently running into this, getting things like <script src=/client/fbd4e5d87f8d7dec1966/main.0.css> injected into the page when attempting to set up mini-css-extract-plugin to generate a global css file.

Expanding upon this, I also need to inject that CSS file into the head as a <link>. I'm using sapper-template as the base, which currently has no pre-defined CSS processing beyond what svelte provides. I've openned an issue about it there: https://github.com/sveltejs/sapper-template/issues/59

@Rich-Harris if we change https://github.com/sveltejs/sapper/blob/master/src/middleware.ts#L483 to .filter(function (file) { return file.match(/\.js$/); }), wouldn't this fix the inclusion of the css files in a script tag?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikku picture nikku  路  4Comments

Snugug picture Snugug  路  4Comments

UnwrittenFun picture UnwrittenFun  路  4Comments

milosdjakovic picture milosdjakovic  路  3Comments

benmccann picture benmccann  路  3Comments