Sapper: [Request] Hash global.css

Created on 1 Nov 2018  路  4Comments  路  Source: sveltejs/sapper

Hello,

Would it be at all possible to hash the global.css file as i'm currently adding a query string to the url every-time I make a change which i push. Would be super handy to have this be done automatically.

Thank you!

Most helpful comment

Yes, I have one public project using this style of setup. The project itself works fine but there's limited documentation etc. as it's a WIP.

  1. CSS entry point: https://github.com/MaxMilton/homie-bot/blob/master/src/client.js#L2
  2. Relevant part of rollup config: https://github.com/MaxMilton/homie-bot/blob/master/rollup.config.js#L37
  3. Custom rollup plugin which handles global CSS (using PostCSS for preprocessing and Purgecss to remove unused styles): https://github.com/MaxMilton/homie-bot/blob/master/rollup-plugins.js#L20-L82

You probably wouldn't need a custom rollup plugin. If you're using plain CSS then you don't need any extra plugins.

All 4 comments

Are you referring to the /static/global.css file in sapper-template? One option would be to import your CSS in a script (e.g. /src/client.js) and handle your global styles with webpack/rollup. Sapper will take care of it and inject it into /dist/client/main.[hash].css.

There was a similar discussion in https://github.com/sveltejs/sapper/issues/474.

Yes i am referring to exactly that. Do you have an example rollup config per chance?

Yes, I have one public project using this style of setup. The project itself works fine but there's limited documentation etc. as it's a WIP.

  1. CSS entry point: https://github.com/MaxMilton/homie-bot/blob/master/src/client.js#L2
  2. Relevant part of rollup config: https://github.com/MaxMilton/homie-bot/blob/master/rollup.config.js#L37
  3. Custom rollup plugin which handles global CSS (using PostCSS for preprocessing and Purgecss to remove unused styles): https://github.com/MaxMilton/homie-bot/blob/master/rollup-plugins.js#L20-L82

You probably wouldn't need a custom rollup plugin. If you're using plain CSS then you don't need any extra plugins.

Thank you @MaxMilton I have successfully implemented this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  路  3Comments

nikku picture nikku  路  4Comments

UnwrittenFun picture UnwrittenFun  路  4Comments

freedmand picture freedmand  路  4Comments

BMorearty picture BMorearty  路  3Comments