Closed edwardhorsford closed 7 years ago
Interesting discussion of auto-combining sass files here: https://github.com/haml/haml/issues/97
There's a grunt-sass-globbing plugin which would enable this for sass files.
Globbing could produce inconsistent results for some users.
The problem with globbing in prototyping land is that not everybody will write CSS that doesn't rely on source order for specificity. Some users won't even realise that is why a css rule is winning/being applied.
We can control the order that gov.uk/prototyping kit dependancies are loaded within the files configuration object but once we'd left it to the user to create sass files/stylesheets we'd have to educate on specificity or somehow allow them to configure their own order in the event of an issue... using config.js perhaps? but that obviously adds complexity for them and us.
yeh I'm not sure what the value would be in adding globbing to the prototype kit - this is normally a performance thing no? In terms of it being easier because of not having to reference them, as paul says that introduces source order issues
@edwardhorsford I like the sentiment but as I said I worry about edge cases and depending on how we implemented it, certain users would either want to opt in/or out of it and then would need to do some hoop jumping.
If it were a simple flag in the config file:
// if true will automatically combine and include your sass files into your prototype
autoIncludeCSS: true
// if true will automatically combine and include your javascript files into your prototype
autoIncludeJavascript: true
Then maybe it would be ok, we'd then we'd need to tell them the dirs to place their Sass and Javascript files.
Do people have the same views for JS?
yeh, same for JS - you can run into problems if you don't know what order things are getting loaded in
@henryhadlow the public folder is generated when you run the app, don't edit anything in there - it'll be overridden when you restart the app.
You need to work in app/
and files inside app/
are copied to public/
and made available to your application from there.
As public is generated each time the app is run, we don't want it to be tracked by Git.
To add a javascript file, put it in app/assets/javascripts - this will then be copied to public/javascripts and you can reference this file by updating the scripts include:
https://github.com/alphagov/govuk_prototype_kit/blob/master/app/views/includes/scripts.html
<script src="/public/javascripts/your-js-file-goes-here.js"></script>
<script src="/public/javascripts/application.js"></script>
Thanks @gemmaleigh! I realised this after a while.
so currently in the kit, anything you put in assets
will be copied to public
, does this solve this issue @edwardhorsford ?
Mostly. I can see the disadvantages of minification may outway the advantages. Since it doesn't seem a big thing, lets close it.
At the moment if you want to serve a file to the root of the app or certain assets you have to do it manually. It would be better if we set up folders where users could place their files.
It would also potentially be handy to do auto combining of sass / js files, so that users don't have to manually reference them.